/*
 * Modern UI theme layer.
 * Restyles existing Bootstrap 3/4/5 + Kartik markup used across the app
 * (navbar, panel/card, tables/GridView, buttons, forms, pagination,
 * breadcrumbs, alerts, login card) without touching any view logic.
 * Loaded after site.css / bsaddons.css via AppAsset.
 */

:root {
    --surface: #ffffff;
    --surface-muted: #f7f8fa;
    --border-color: #e5e8ec;
    --text-primary: #1f2937;
    --text-muted: #6b7280;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
    --radius-sm: .375rem;
    --radius-md: .625rem;
    --radius-lg: 1rem;
    --accent: #1e81b0;
}

html, body {
    background-color: var(--surface-muted);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Navbar ---------- */
.navbar {
    box-shadow: var(--shadow-md);
    padding-top: .6rem;
    padding-bottom: .6rem;
}

.navbar-brand {
    font-weight: 600;
    letter-spacing: .01em;
}

.navbar .nav-link {
    border-radius: var(--radius-sm);
    transition: background-color .15s ease, opacity .15s ease;
}

.navbar-dark .nav-link:hover,
.navbar-dark .nav-link:focus {
    background-color: rgba(255, 255, 255, .12);
}

.navbar .dropdown-menu {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: .5rem;
    margin-top: .5rem;
    animation: theme-dropdown-in .12s ease-out;
}

.navbar .dropdown-item {
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    transition: background-color .15s ease;
}

.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus {
    background-color: var(--surface-muted);
}

@keyframes theme-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Panels / Cards (Bootstrap 3 leftovers + Bootstrap 4/5 cards) ---------- */
.panel,
.card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel-heading,
.card-header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    font-weight: 600;
    padding: .9rem 1.25rem;
}

.panel-body,
.card-body {
    padding: 1.25rem;
}

.panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* ---------- Tables / Kartik GridView ---------- */
.table {
    background-color: var(--surface);
}

.table thead th {
    background-color: var(--surface-muted);
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table td {
    vertical-align: middle;
    border-color: var(--border-color);
}

.table-hover tbody tr:hover,
.grid-view .table tbody tr:hover {
    background-color: var(--surface-muted);
}

.grid-view {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.grid-view .table {
    margin-bottom: .5rem;
}

.summary {
    color: var(--text-muted);
    font-size: .85rem;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: transform .05s ease, box-shadow .15s ease, filter .15s ease;
}

.btn:hover {
    filter: brightness(.96);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info {
    box-shadow: var(--shadow-sm);
}

/* ---------- Forms ---------- */
.form-control,
.form-select,
.custom-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
}

.form-control:focus,
.form-select:focus,
.custom-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(30, 129, 176, .15);
}

label,
.control-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* ---------- Pagination ---------- */
.pagination .page-link {
    border-radius: var(--radius-sm);
    margin: 0 .15rem;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.pagination .page-item.active .page-link {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    background-color: transparent;
    padding-left: 0;
}

/* ---------- Alerts ---------- */
.alert {
    border: none;
    border-left: 4px solid transparent;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.alert-success { border-left-color: #28a745; }
.alert-danger  { border-left-color: #dc3545; }
.alert-warning { border-left-color: #ffc107; }
.alert-info    { border-left-color: #17a2b8; }

/* ---------- Main content spacing ---------- */
main#main,
main[role="main"] {
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* ---------- Footer ---------- */
footer#footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--surface) !important;
}

/* ---------- Login card ---------- */
body.theme-login-body {
    min-height: 100%;
    background: linear-gradient(135deg, #1e81b0 0%, #164863 100%);
}

.theme-login-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.theme-login-card .panel-heading,
.theme-login-card .card-header {
    background: linear-gradient(135deg, #1e81b0 0%, #164863 100%);
    color: #fff;
    border-bottom: none;
}

.theme-login-card .form-control {
    border-color: var(--border-color) !important;
}

@media (max-width: 767px) {
    main#main,
    main[role="main"] {
        padding-top: 1rem;
    }

    .panel-body,
    .card-body {
        padding: 1rem;
    }
}

/* ---------- Module navbar gradients (brand identity per module) ---------- */
.navbar-theme-blue {
    background: linear-gradient(135deg, #1e81b0 0%, #164863 100%) !important;
}

.navbar-theme-green {
    background: linear-gradient(135deg, #2c7a4b 0%, #1b4d30 100%) !important;
}

.navbar-theme-purple {
    background: linear-gradient(135deg, #574b90 0%, #362f5c 100%) !important;
}

/* ---------- Dashboard hero (module home / index pages) ---------- */
.dashboard-hero {
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.75rem;
    color: #fff;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-md);
}

.dashboard-hero h1,
.dashboard-hero h2,
.dashboard-hero h3,
.dashboard-hero h4 {
    color: #fff;
    margin-bottom: .35rem;
}

.dashboard-hero p {
    color: rgba(255, 255, 255, .85);
    margin-bottom: 0;
}

.dashboard-hero.hero-blue {
    background: linear-gradient(135deg, #1e81b0 0%, #164863 100%);
}

.dashboard-hero.hero-green {
    background: linear-gradient(135deg, #2c7a4b 0%, #1b4d30 100%);
}

.dashboard-hero.hero-purple {
    background: linear-gradient(135deg, #574b90 0%, #362f5c 100%);
}

/* ---------- Quick-link cards (module dashboards) ---------- */
.quick-link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1rem;
    min-height: 140px;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}

.quick-link-card:hover,
.quick-link-card:focus {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    color: var(--text-primary);
}

.quick-link-card .quick-link-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .65rem;
    font-size: 1.35rem;
    color: #fff;
    flex-shrink: 0;
}

.quick-link-card .quick-link-label {
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.25;
}

.icon-bg-blue   { background: linear-gradient(135deg, #1e81b0, #164863); }
.icon-bg-green  { background: linear-gradient(135deg, #2c7a4b, #1b4d30); }
.icon-bg-purple { background: linear-gradient(135deg, #574b90, #362f5c); }
.icon-bg-pink   { background: linear-gradient(135deg, #c44569, #8e3652); }

/* ---------- Site home welcome card (logo left, greeting right) ---------- */
.site-welcome-card {
    gap: 1rem;
}

.site-welcome-logo {
    width: 84px;
    height: 84px;
    background: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .5rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.site-welcome-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
