@import url('https://fonts.googleapis.com/css2?family=Urbanist:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --bg-main: #FAF9F6;      /* Premium warm white/stone background */
    --bg-card: #FFFFFF;
    --primary: #D97706;      /* Rich amber brand color */
    --primary-hover: #B45309;
    --primary-light: #FEF3C7;
    --secondary: #6B7280;
    --secondary-light: #F3F4F6;
    --text-dark: #1C1917;    /* Charcoal dark stone */
    --text-muted: #78716C;   /* Muted warm grey */
    --border: #E7E5E4;       /* Stone 200 border */
    --success: #16A34A;
    --success-light: #DCFCE7;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --warning: #EAB308;
    --warning-light: #FEF9C3;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;       /* Premium larger roundings */
    
    --shadow-sm: 0 1px 2px 0 rgba(28, 25, 23, 0.05);
    --shadow-md: 0 8px 16px -2px rgba(28, 25, 23, 0.04), 0 2px 6px -1px rgba(28, 25, 23, 0.03);
    --shadow-lg: 0 20px 25px -5px rgba(28, 25, 23, 0.08), 0 10px 10px -5px rgba(28, 25, 23, 0.04);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Urbanist', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-dark);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
}

/* Single column Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Premium Top Header Menu */
.main-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    min-height: 75px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(28, 25, 23, 0.02);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.header-brand img {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.header-brand span {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--primary);
    letter-spacing: -0.03em;
}

/* Top Horizontal Nav */
.header-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
}

.header-nav-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    transition: var(--transition);
}

.header-nav-item a:hover {
    background-color: var(--secondary-light);
    color: var(--text-dark);
}

.header-nav-item.active a {
    background-color: var(--primary-light);
    color: var(--primary);
}

.header-nav-item a svg {
    width: 18px;
    height: 18px;
}

/* Header Right Area */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--secondary-light);
    padding: 6px 12px;
    border-radius: 50px;
    max-width: 220px;
}

.header-user-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.header-user-name {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-dark);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hamburger button for Mobile */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-dark);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 80px; /* Space for mobile navigation */
}

/* Page Title Info Area */
.page-title-bar {
    padding: 24px 32px 0 32px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Page Container */
.page-container {
    padding: 24px 32px 32px 32px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.15);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 14px rgba(217, 119, 6, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--secondary-light);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: var(--border);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #B91C1C;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #15803D;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-dark);
}

.btn-outline:hover {
    background-color: var(--secondary-light);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

/* Dashboard Summary Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background-color: var(--success-light);
    color: var(--success);
}

.stat-icon.danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.stat-icon.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.03em;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background-color: var(--bg-main);
    padding: 16px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 600;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background-color: var(--bg-main);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.75rem;
}

.badge-primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background-color: var(--success-light);
    color: var(--success);
}

.badge-danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge-warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.badge-secondary {
    background-color: var(--secondary-light);
    color: var(--text-muted);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-dark);
    font-size: 0.9rem;
    outline: none;
    font-weight: 600;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder {
    color: #9CA3AF;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 0;
}

.form-row > .form-group {
    flex: 1;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(28, 25, 23, 0.4);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.75rem;
    line-height: 1;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Mobile Nav Bottom Bar */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 95;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(28, 25, 23, 0.03);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 700;
    gap: 4px;
    transition: var(--transition);
}

.mobile-nav-item svg {
    width: 20px;
    height: 20px;
}

.mobile-nav-item.active {
    color: var(--primary);
}

/* ---------------------------------------------------- */
/* PREMIUM LOGIN SCREEN STYLINGS */
/* ---------------------------------------------------- */
.login-body {
    background-color: #FAF9F6;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Moving fluid background blobs */
.login-body::before,
.login-body::after {
    content: '';
    position: absolute;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.55;
    animation: floatBlob 16s infinite alternate ease-in-out;
}

.login-body::before {
    background-color: #FED7AA; /* Warm peach */
    top: -5%;
    left: 10%;
}

.login-body::after {
    background-color: #FEF3C7; /* Soft amber */
    bottom: 0%;
    right: 10%;
    animation-delay: -8s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 40px) scale(1.15); }
}

.login-card {
    background-color: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(120, 113, 108, 0.12);
    width: 100%;
    max-width: 440px;
    padding: 48px 40px;
    text-align: center;
    transition: var(--transition);
}

.login-card:hover {
    box-shadow: 0 30px 60px -10px rgba(120, 113, 108, 0.18);
}

.login-brand {
    margin-bottom: 32px;
}

.login-logo {
    height: 65px;
    margin-bottom: 20px;
    object-fit: contain;
}

.login-title {
    font-weight: 900;
    font-size: 1.75rem;
    margin-bottom: 8px;
    color: var(--text-dark);
    letter-spacing: -0.04em;
}

.login-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.login-card .form-control {
    background-color: rgba(255, 255, 255, 0.7);
    border-color: rgba(231, 229, 228, 0.9);
}

.login-card .form-control:focus {
    background-color: #FFFFFF;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.9rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.alert-success {
    background-color: var(--success-light);
    color: var(--success);
    border-color: #BBF7D0;
}

.alert-danger {
    background-color: var(--danger-light);
    color: var(--danger);
    border-color: #FECACA;
}

/* ---------------------------------------------------- */
/* RESPONSIVE LAYOUT adjustments */
/* ---------------------------------------------------- */
@media (max-width: 1024px) {
    .main-header {
        padding: 0 20px;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Collapsible Navigation in Header for Mobile */
    .header-nav {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 75px;
        left: 0;
        right: 0;
        background-color: var(--bg-card);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        padding: 20px;
        gap: 8px;
        z-index: 100;
    }
    
    .header-nav.active {
        display: flex;
    }
    
    .header-nav-item {
        width: 100%;
    }
    
    .header-nav-item a {
        width: 100%;
        padding: 12px 16px;
    }
    
    .header-user-profile {
        display: none; /* Hide top user profile card on mobile, logout stays */
    }
    
    .mobile-nav {
        display: flex;
    }
    
    .page-container {
        padding: 20px;
    }
    
    .page-title-bar {
        padding: 20px 20px 0 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .header-actions .btn span {
        display: none;
    }
    .login-card {
        padding: 40px 28px;
    }
}

/* ==================================================== */
/* TAT 27 MOBILE RESPONSIVE REVAMP */
/* ==================================================== */

/* Desktop view: show table, hide cards */
.mobile-cards-container {
    display: none;
}

/* Responsive button labels: show full text on desktop, short text on mobile */
.btn-label-mobile {
    display: none;
}
.btn-label-full {
    display: inline;
}

/* Mobile Bottom Sheet Menu styles */
.mobile-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(28, 25, 23, 0.4);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.mobile-sheet-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-sheet-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: -100%;
    background-color: var(--bg-card);
    border-radius: 24px 24px 0 0;
    z-index: 1001;
    box-shadow: 0 -10px 25px rgba(28, 25, 23, 0.15);
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: 30px;
}

.mobile-sheet-menu.active {
    bottom: 0;
}

.mobile-sheet-header {
    padding: 20px 24px 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.mobile-sheet-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.mobile-sheet-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
}

.mobile-sheet-body {
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-dark);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    transition: var(--transition);
}

.mobile-sheet-item svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.mobile-sheet-item:hover, .mobile-sheet-item.active {
    background-color: var(--secondary-light);
}

.mobile-sheet-item.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

.mobile-sheet-item.active svg {
    color: var(--primary);
}

/* Mobile Media Query overrides */
@media (max-width: 768px) {
    /* Hide top header burger and user blocks on mobile */
    .mobile-menu-toggle {
        display: none !important;
    }
    .header-right {
        display: none !important;
    }
    .header-nav {
        display: none !important;
    }
    .main-header {
        justify-content: center !important; /* Center the logo */
        padding: 0 16px !important;
        min-height: 60px !important;
    }
    
    /* Center dashboard title block and action buttons */
    .dashboard-header {
        flex-direction: column !important;
        text-align: center !important;
        align-items: center !important;
        gap: 16px !important;
    }
    .dashboard-actions {
        justify-content: center !important;
        width: 100% !important;
        gap: 8px !important;
    }
    .dashboard-actions .btn {
        flex: 1 !important;
        min-width: 100px !important;
        font-size: 0.8rem !important;
        padding: 8px 12px !important;
    }
    
    /* Center all page titles on mobile */
    .page-title-bar {
        text-align: center !important;
        margin-bottom: 20px !important;
    }
    .page-title-bar h2 {
        text-align: center !important;
        width: 100% !important;
    }

    /* Table cards conversion on mobile */
    .table-responsive {
        display: none !important;
    }
    form .table-responsive,
    .table-responsive.item-table-container {
        display: block !important;
    }
    .mobile-cards-container {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
        margin-top: 12px;
        padding: 12px 0;
        width: 100%;
    }
    /* Show short label on mobile, hide full label */
    .btn-label-mobile {
        display: inline !important;
    }
    .btn-label-full {
        display: none !important;
    }
    .mobile-card {
        background: white;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 16px;
        box-shadow: var(--shadow-sm);
    }
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px dashed var(--border);
        font-size: 0.85rem;
        align-items: center;
    }
    .mobile-card-row:last-child {
        border-bottom: none;
    }
    .mobile-card-label {
        font-weight: 700;
        color: var(--text-muted);
    }
    .mobile-card-value {
        font-weight: 700;
        color: var(--text-dark);
        text-align: right;
    }
    
    /* Stack card headers on mobile */
    .card-header {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 12px !important;
    }
    .card-header > div {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    /* Stack Kasa filter form elements on mobile */
    .kasa-filter-form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        width: 100% !important;
    }
    .kasa-filter-form > div {
        width: 100% !important;
        flex: none !important;
    }
    .kasa-clear-btn-wrapper {
        justify-content: center !important;
        margin-top: 8px !important;
        display: flex !important;
    }
}
