/* assets/css/style.css */

/* --- GLOBAL VARIABLES & THEME --- */
:root {
    /* Branding Colors (Dynamically set in header.php, defaults here) */
    --danger-color: #e74c3c;
    /* New App Shell Variables */
    --header-height: 70px;
    --header-bg: rgba(30, 30, 30, 0.95);
    --header-border: 1px solid #333;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --drawer-bg: #252525;
    --drawer-width: 280px;
    --medium-bg: #2c2c2c;
    --dark-bg: #1a1a1a;
}

body {
    background-color: #121212; /* Deeper black for modern feel */
    font-family: 'Inter', 'Roboto', sans-serif;
    color: var(--text-primary);
    margin: 0;
    padding-top: var(--header-height); /* Push content down to account for fixed header */
}

/* =========================================
   APP HEADER & NAVIGATION (NEW SYSTEM)
   ========================================= */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--header-bg);
    border-bottom: var(--header-border);
    backdrop-filter: blur(10px); /* Glassmorphism effect */
    z-index: 1000;
    display: flex;
    align-items: center;
}

.header-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Logo --- */
.brand-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}
.text-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.text-logo i { color: var(--primary-color); }

/* --- Desktop Navigation --- */
.desktop-nav {
    display: flex;
    gap: 25px;
    margin-left: 40px;
    margin-right: auto; /* Pushes user actions to the right */
}

.desktop-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 8px 0;
    position: relative;
    transition: color 0.2s;
}

.desktop-nav a:hover, .desktop-nav a.active {
    color: #fff;
}

/* Underline animation for active links */
.desktop-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s;
}
.desktop-nav a:hover::after, .desktop-nav a.active::after {
    width: 100%;
}

/* --- Right Side Actions --- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Org Switcher (Desktop) */
.org-switcher-desktop {
    position: relative;
    margin-right: 10px;
    display: flex;
    align-items: center;
}
.switcher-icon {
    position: absolute;
    left: 10px;
    color: #888;
    pointer-events: none;
    z-index: 1;
}
.org-switcher-desktop select {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ddd;
    padding: 6px 10px 6px 32px; /* Space for icon */
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    margin: 0;
    height: auto;
}
.org-switcher-desktop select:hover {
    border-color: #666;
}

/* Profile Pill */
.profile-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #2a2a2a;
    padding: 4px 12px 4px 4px;
    border-radius: 50px;
    text-decoration: none;
    color: #e0e0e0;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.profile-pill:hover {
    border-color: #555;
    background: #333;
}
.avatar-circle {
    width: 28px;
    height: 28px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}
.profile-name { font-size: 0.9rem; font-weight: 500; }

.icon-btn {
    color: #aaa;
    font-size: 1.1rem;
    transition: color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}
.icon-btn:hover { color: #fff; }

/* Header Dropdowns */
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropbtn {
    background: none; border: none; color: var(--text-secondary);
    font-size: 0.95rem; font-weight: 500; cursor: pointer; padding: 8px 0;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
}
.nav-dropbtn:hover { color: #fff; }
.nav-drop-content {
    display: none;
    position: absolute;
    top: 100%; left: 0;
    background-color: #2a2a2a;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 8px 0;
    z-index: 1100;
    border: 1px solid #444;
}
.nav-dropdown:hover .nav-drop-content { display: block; }
.nav-drop-content a {
    color: #ccc;
    padding: 10px 20px;
    display: block;
    font-weight: normal;
    font-size: 0.9rem;
    text-decoration: none;
}
.nav-drop-content a:hover {
    background-color: var(--primary-color);
    color: #fff;
}
.nav-drop-content a::after { display: none; } /* No underline in dropdown */
.dropdown-divider { height: 1px; background: #444; margin: 5px 0; }
.dropdown-header { display: block; padding: 5px 20px; font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 1px; }

/* Action Buttons (e.g. Free Trial) */
.btn-highlight {
    background: var(--primary-color);
    color: #fff;
    padding: 8px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-highlight:hover { background: var(--primary-hover); }

/* --- Mobile Specific Nav Elements --- */
.mobile-toggle { 
    display: none; 
    background: transparent; 
    border: none; 
    color: #fff; 
    font-size: 1.5rem; 
    cursor: pointer;
    padding: 15px; /* Larger tap area */
    margin-right: -15px; /* Align visual right while keeping tap area */
    z-index: 1100; /* Ensure above everything */
    touch-action: manipulation; /* Disables double-tap zoom for faster clicks */
}

/* Important: Make icon ignore clicks so they register on the button */
.mobile-toggle i {
    pointer-events: none;
}

/* Drawer */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: -100%; /* Hidden off-screen right */
    width: var(--drawer-width);
    height: 100vh;
    background-color: var(--drawer-bg);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}
.mobile-drawer.open { right: 0; }

.drawer-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #333;
}
.drawer-title { font-size: 1.1rem; font-weight: bold; color: #fff; }
.drawer-close { background: none; border: none; color: #aaa; font-size: 1.2rem; cursor: pointer; }

.drawer-content { padding: 20px; overflow-y: auto; }

.drawer-links a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 10px;
    color: #ccc;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 5px;
    font-size: 1rem;
}
.drawer-links a:hover, .drawer-links a.active {
    background-color: rgba(255,255,255,0.05);
    color: #fff;
}
.drawer-links i { width: 20px; text-align: center; color: var(--primary-color); }
.drawer-divider { border: 0; border-top: 1px solid #444; margin: 15px 0; }

.mobile-org-switcher {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.mobile-org-switcher label { display: block; color: #888; font-size: 0.8rem; margin-bottom: 8px; }
.mobile-org-switcher select { width: 100%; margin: 0; padding: 10px; background: #333; color: white; border: 1px solid #555; border-radius: 4px; }

/* Overlay */
.mobile-drawer-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1500;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}
.mobile-drawer-overlay.active { opacity: 1; pointer-events: auto; }


/* =========================================
   GENERAL LAYOUT & UI COMPONENTS
   ========================================= */

.container {
    padding: 30px;
    max-width: 1300px;
    margin: 0 auto;
}

h1 { font-weight: 700; color: #fff; margin-top: 20px; }
h2 { font-weight: 700; color: #fff; }
small { color: #aaa; }

/* --- General Table Styles --- */
table {
    width: 100%;
    border-spacing: 0;
    margin-top: 20px;
    background-color: var(--medium-bg, #2c2c2c);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #444;
}
table tr {
    display: table-row; /* Standard row behavior for desktop */
}
table th, table td {
    padding: 16px;
    text-align: left;
    border-left: 1px solid #444;
}
table th:first-child, table td:first-child {
    border-left: none;
}
table th {
    background-color: #333;
    font-weight: 500;
    color: #fff;
    vertical-align: middle;
}
table tbody tr {
    border-bottom: 1px solid #444;
}
table tbody tr:last-child {
    border-bottom: none;
}
table tbody tr:hover {
    background-color: #383838;
}

/* Table Header Links */
table th a {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    color: #d1d1d1;
    text-decoration: none;
}
th a:hover, a.active-sort {
    color: var(--primary-color);
}
td a {
    color: #8ab4f8;
    font-weight: 500;
    text-decoration: none;
}
td a:hover {
    color: #aecbfa;
    text-decoration: underline;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #ccc;
}
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], input[type="color"], select, textarea {
    width: 100%;
    padding: 12px;
    margin-top: 4px;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 5px;
    box-sizing: border-box;
    color: #e0e0e0;
    transition: border-color 0.3s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color, #5a95ff);
}

/* --- Buttons --- */
.btn, button {
    padding: 12px 20px;
    text-decoration: none;
    border-radius: 5px;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}
.btn-primary, button[type="submit"] { background-color: var(--primary-color, #5a95ff); }
.btn-primary:hover, button[type="submit"]:hover { background-color: var(--primary-hover, #7aaaff); }
.btn-danger { background-color: var(--danger-color, #e74c3c); }

/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}
.dashboard-card {
    background-color: var(--medium-bg, #2c2c2c);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #444;
}
.dashboard-card h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: #ccc;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}
.dashboard-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.dashboard-card li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #3a3a3a;
}
.dashboard-card li:last-child { border-bottom: none; }
.dashboard-card .chart-container {
    position: relative;
    height: 300px;
    margin-top: 15px;
}
.dashboard-card a {
    color: var(--primary-color);
    text-decoration: none;
}
.dashboard-card a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* --- List Cards --- */
.management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}
.list-card {
    background-color: var(--medium-bg, #2c2c2c);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #444;
    overflow: hidden; 
}
.list-card h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: #ccc;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}
.list-card ul {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}
.list-card li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 5px;
    transition: background-color 0.2s;
}
.list-card li:hover {
    background-color: #383838;
}
.list-card .delete-btn {
    color: var(--danger-color, #e74c3c);
    text-decoration: none;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 0 5px;
}
.add-form {
    display: flex;
    gap: 10px;
}

/* Responsiveness for images/iframes */
.list-card img, .dashboard-card img, 
.list-card video, .dashboard-card video,
.list-card iframe, .dashboard-card iframe {
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 5px;
}
.pagination a, .pagination span {
    color: #ccc;
    text-decoration: none;
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 5px;
    transition: background-color 0.2s, color 0.2s;
}
.pagination a:hover {
    background-color: var(--primary-color, #5a95ff);
    color: #ffffff;
    border-color: var(--primary-color, #5a95ff);
}
.pagination span.current {
    background-color: var(--primary-color, #5a95ff);
    color: #ffffff;
    border-color: var(--primary-color, #5a95ff);
    font-weight: bold;
}
.pagination span.disabled {
    color: #666;
    cursor: not-allowed;
}

/* --- Form Layouts --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}
.form-column {
    display: flex;
    flex-direction: column;
}

/* --- Filters & Toggles --- */
.filter-bar {
    display: none;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background-color: var(--medium-bg, #2c2c2c);
    border-radius: 8px;
    border: 1px solid #444;
    margin-bottom: 20px;
}
.filter-bar.visible {
    display: flex;
}
.filter-bar .form-group {
    margin-bottom: 0;
    flex-grow: 1;
}
.filter-bar label {
    font-size: 0.9rem;
}

.column-toggle-container {
    padding: 8px 15px;
    background-color: #252525;
    border: 1px solid #444;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 15px;
}

/* --- Misc --- */
.sortable-ghost {
    opacity: 0.4;
    background-color: var(--primary-color);
}
.list-thumbnail-img {
    max-width: 60px;
    max-height: 45px;
    border-radius: 4px;
    object-fit: cover;
}
td[data-column="thumbnail"],
th[data-column="thumbnail"] {
    flex: 0 0 80px;
    text-align: center;
}

.document-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}
.document-list li {
    background-color: #333;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.document-list a {
    color: #8ab4f8;
    text-decoration: none;
    font-weight: 500;
}
.document-list a:hover {
    text-decoration: underline;
}

/* Install Banner (Mobile PWA) */
.install-banner {
    display: none; /* Hidden by default, shown via JS */
    position: fixed;
    bottom: 20px;
    left: 15px;
    right: 15px;
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    z-index: 9999;
    padding: 15px;
    color: white;
    flex-direction: column;
    gap: 10px;
    animation: slideUp 0.5s ease-out;
}
.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}
.install-app-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
}
.install-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.install-text strong { font-size: 1.1rem; }
.install-text span { font-size: 0.85rem; color: #aaa; }
.install-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 5px;
}
.install-instructions {
    font-size: 0.9rem;
    text-align: center;
    background: rgba(255,255,255,0.05);
    padding: 8px;
    border-radius: 6px;
    color: #ddd;
}
.install-instructions i { color: var(--primary-color); margin: 0 3px; }

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 769px) {
    .install-banner { display: none !important; }
}


/* =========================================
   RESPONSIVE (MOBILE) STYLES
   ========================================= */

@media (max-width: 992px) {
    /* Hide desktop elements, show mobile toggle */
    .desktop-nav, .org-switcher-desktop, .profile-pill, .icon-btn { display: none !important; }
    .mobile-toggle { display: block; }
}

@media screen and (max-width: 768px) {
    /* General Mobile Layout */
    .container { padding: 15px; }
    
    /* Buttons */
    .btn, button, .top-bar .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
        margin-bottom: 10px;
        display: flex;
        align-items: center;
    }
    
    .top-bar {
        flex-direction: column;
        gap: 10px;
        align-items: stretch !important;
        margin-bottom: 20px;
    }
    
    /* Grids */
    .dashboard-grid, .management-grid, .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* --- Responsive Table (Card View) --- */
    table thead { display: none; }
    
    table tr {
        display: flex; /* Switch to flex column for cards */
        flex-direction: column;
        margin-bottom: 20px;
        border: 1px solid #444;
        border-radius: 8px;
        background-color: rgba(255,255,255,0.02);
        overflow: hidden;
    }
    
    table th, table td {
        flex: 1 1 auto;
        text-align: right;
        padding: 12px 15px;
        padding-left: 50%; /* Space for label */
        position: relative;
        border-bottom: 1px solid #444;
        border-left: none;
        white-space: normal;
        display: block;
    }
    
    table td:last-child, table tr:last-child td:last-child {
        border-bottom: none;
    }
    
    table td:before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        top: 12px;
        width: 45%;
        padding-right: 10px;
        text-align: left;
        font-weight: bold;
        color: #888;
        font-size: 0.9em;
        text-transform: uppercase;
    }
    
    /* Fix for Actions column on mobile */
    td[data-label="Actions"] {
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        padding-left: 15px; /* Reset padding */
        text-align: right;
        background-color: rgba(0,0,0,0.2); /* Distinguish action area */
    }
    td[data-label="Actions"]:before {
        display: none; /* Hide label for actions row */
    }
}