/*
 * Theme System - Light/Dark Mode
 * PANDORA Water Monitoring System
 */

/* ========== ROOT VARIABLES (Light Mode Default) ========== */
:root {
    /* Primary Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-hover: #f0f0f0;
    
    /* Text Colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #999999;
    --text-inverse: #ffffff;
    
    /* Accent Colors */
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --accent-light: #ebf5fb;
    
    /* Status Colors */
    --status-success: #27ae60;
    --status-warning: #f39c12;
    --status-danger: #e74c3c;
    --status-info: #3498db;
    
    /* Border & Shadow */
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Chart Colors */
    --chart-primary: #3498db;
    --chart-secondary: #e74c3c;
    --chart-tertiary: #f39c12;
    --chart-quaternary: #27ae60;
    --chart-quinary: #9b59b6;
    
    /* Input & Form */
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --input-focus-border: #3498db;
    --input-placeholder: #6c757d;
    
    /* Navbar */
    --navbar-bg: #2c3e50;
    --navbar-text: #ecf0f1;
    --navbar-hover: #34495e;
    
    /* Sidebar */
    --sidebar-bg: #34495e;
    --sidebar-text: #ecf0f1;
    --sidebar-hover: #2c3e50;
    
    /* Footer */
    --footer-bg: #2c3e50;
    --footer-text: #ecf0f1;
    /* Logo / Favicon sizes */
    --logo-size: 120px;
    --favicon-size: 96px;
}

/* ========== DARK MODE VARIABLES ========== */
[data-theme="dark"] {
    /* Primary Colors */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #242424;
    --bg-hover: #333333;
    
    /* Text Colors - IMPROVED CONTRAST */
    --text-primary: #f0f0f0;        /* Brighter for better readability */
    --text-secondary: #c0c0c0;      /* Lighter gray */
    --text-muted: #909090;          /* More visible muted text */
    --text-inverse: #1a1a1a;
    
    /* Accent Colors */
    --accent-color: #5dade2;        /* Brighter blue for dark mode */
    --accent-hover: #7fc4ed;
    --accent-light: #1f2933;
    
    /* Status Colors - BRIGHTER for dark mode */
    --status-success: #2ecc71;
    --status-warning: #f4d03f;      /* Brighter yellow */
    --status-danger: #ec7063;       /* Softer red */
    --status-info: #5dade2;
    
    /* Border & Shadow */
    --border-color: #404040;
    --border-light: #353535;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    
    /* Chart Colors (brighter for dark mode) */
    --chart-primary: #5dade2;
    --chart-secondary: #ec7063;
    --chart-tertiary: #f4d03f;
    --chart-quaternary: #58d68d;
    --chart-quinary: #bb8fce;
    
    /* Input & Form - IMPROVED CONTRAST */
    --input-bg: #2d2d2d;
    --input-border: #505050;        /* Lighter border */
    --input-focus-border: #5dade2;
    --input-placeholder: #909090;   /* More visible placeholder */
    
    /* Navbar */
    --navbar-bg: #1a1a1a;
    --navbar-text: #f0f0f0;         /* Brighter text */
    --navbar-hover: #2d2d2d;
    
    /* Sidebar */
    --sidebar-bg: #242424;
    --sidebar-text: #f0f0f0;        /* Brighter text */
    --sidebar-hover: #2d2d2d;
    
    /* Footer */
    --footer-bg: #1a1a1a;
    --footer-text: #c0c0c0;         /* Lighter footer text */
}

/* ========== BASE STYLES ========== */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========== CARDS & CONTAINERS ========== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

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

.card-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.card-body {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* ========== TABLES ========== */
.table {
    color: var(--text-primary);
}

.table thead th {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.table tbody tr {
    background-color: var(--bg-card);
    border-color: var(--border-light);
}

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

.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bg-secondary);
}

/* ========== BUTTONS ========== */
.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--text-inverse);
}

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

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

.btn-warning {
    background-color: var(--status-warning);
    border-color: var(--status-warning);
}

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

/* ========== FORMS & INPUTS ========== */
.form-control {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
}

.form-control:focus {
    background-color: var(--input-bg);
    border-color: var(--input-focus-border);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-control::placeholder {
    color: var(--input-placeholder);
}

.form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
}

/* ========== NAVBAR ========== */
.navbar {
    background-color: var(--navbar-bg) !important;
}

.navbar-brand,
.navbar .nav-link {
    color: var(--navbar-text) !important;
}

.navbar .nav-link:hover {
    background-color: var(--navbar-hover);
    border-radius: 4px;
}

/* ========== THEME TOGGLE BUTTON ========== */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-color);
    border: none;
    color: var(--text-inverse);
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--accent-hover);
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* ========== CHART TYPE TOGGLE ========== */
.chart-toggle {
    display: inline-flex;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px;
}

.chart-toggle button {
    padding: 8px 16px;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.chart-toggle button.active {
    background-color: var(--accent-color);
    color: var(--text-inverse);
}

.chart-toggle button:hover:not(.active) {
    background-color: var(--bg-hover);
}

/* ========== STATUS BADGES ========== */
.badge-success {
    background-color: var(--status-success);
}

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

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

.badge-info {
    background-color: var(--status-info);
}

/* ========== DEVICE CONTROL TOGGLE SWITCH ========== */
.device-control-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.device-control-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: 0.4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.device-control-toggle input:checked + .toggle-slider {
    background-color: var(--status-success);
}

.device-control-toggle input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* ========== STATUS INDICATOR (Green/Red Light) ========== */
.status-indicator {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin: 0 auto; /* center inside the table cell */
    animation: pulse 1.8s infinite;
}

.status-indicator.online {
    background-color: var(--status-success);
    box-shadow: 0 0 6px var(--status-success);
}

.status-indicator.offline {
    background-color: var(--status-danger);
    box-shadow: 0 0 6px var(--status-danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ========== FOOTER ========== */
.footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 20px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
}

.footer a:hover {
    color: var(--accent-hover);
}

/* ========== MODAL ========== */
.modal-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.modal-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* Modal body improvements */
.modal .modal-body {
    padding: 0;
    max-height: 70vh;
    overflow-y: auto;
}

/* ========== ALERTS ========== */
.alert {
    border-radius: 6px;
}

.alert-success {
    background-color: rgba(39, 174, 96, 0.1);
    border-color: var(--status-success);
    color: var(--status-success);
}

.alert-warning {
    background-color: rgba(243, 156, 18, 0.1);
    border-color: var(--status-warning);
    color: var(--status-warning);
}

.alert-danger {
    background-color: rgba(231, 76, 60, 0.1);
    border-color: var(--status-danger);
    color: var(--status-danger);
}

.alert-info {
    background-color: rgba(52, 152, 219, 0.1);
    border-color: var(--status-info);
    color: var(--status-info);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .theme-toggle {
        bottom: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .chart-toggle button {
        padding: 6px 12px;
        font-size: 14px;
    }
}

/* Responsive logo size for small screens */
@media (max-width: 768px) {
    :root {
        --logo-size: 64px;
    }
    .logo-badge.no-badge-bg {
        width: var(--logo-size);
        height: var(--logo-size);
    }
}

/* ========== PROFILE SECTION ========== */
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.profile-header {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    padding: 40px 30px;
    display: flex;
    align-items: center;
    gap: 25px;
    color: white;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    color: white;
    border: 4px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.profile-header-info h3 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
}

.profile-header-info p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

/* ========== LOGO BADGE (Shared) ========== */
.logo-badge {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    overflow: hidden;
}

.logo-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* White, larger logo utility */
.logo-white {
    /* scale to parent height so aspect ratio is preserved and no clipping occurs */
    width: auto !important;
    height: 100% !important;
    max-width: 100%;
    object-fit: contain;
    /* Force white rendering for most colored logos */
    filter: grayscale(1) brightness(0) invert(1) saturate(10) contrast(1);
    display: block;
}

/* Variant to remove white badge background (use on dark navbars) */
.logo-badge.no-badge-bg {
    width: var(--logo-size);
    height: var(--logo-size);
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: visible; /* allow the img to show fully */
    border-radius: 0;   /* no circular crop when using no-badge-bg */
}
/* Ensure the image uses the full parent height explicitly */
.logo-badge.no-badge-bg img.logo-white {
    height: var(--logo-size) !important;
    width: auto !important;
    max-width: none !important;
}

/* SVG white logo - preserve as-is (no filters) */
.logo-white-svg {
    filter: none !important;
    height: var(--logo-size) !important;
    width: auto !important;
}

/* Fallback: target any image with Logo in filename to ensure white/color override and sizing
   This helps if some pages still reference /static/Logo.png directly */
img[src*="Logo.png"] {
    height: var(--logo-size) !important;
    width: auto !important;
    max-width: none !important;
    filter: grayscale(1) brightness(0) invert(1) saturate(10) contrast(1) !important; /* Make PNG logos white */
    overflow: visible !important;
    position: relative !important;
    z-index: 9999 !important;
}

img[src*="Logo-white.svg"] {
    height: var(--logo-size) !important;
    width: auto !important;
    max-width: none !important;
    filter: grayscale(1) brightness(0) invert(1) saturate(10) contrast(1) !important;
    overflow: visible !important;
    position: relative !important;
    z-index: 9999 !important;
}

/* Also ensure header won't clip */
.header, .header * {
    overflow: visible !important;
}
/* Ensure header doesn't clip large logo and logo sits above other content */
.header {
    overflow: visible !important;
}
.logo-badge.no-badge-bg {
    position: relative;
    z-index: 9999;
}

.profile-section {
    padding: 30px;
    border-bottom: 1px solid var(--border-light);
}

.profile-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 25px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--accent-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-grid-single {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    max-width: 600px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label i {
    color: var(--accent-color);
    font-size: 16px;
}

.form-group label .required {
    color: var(--status-danger);
    margin-left: 4px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: all 0.3s ease;
    font-family: inherit;
    min-height: 20px;
}

.form-input:focus {
    outline: none;
    border-color: var(--input-focus-border);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-input:focus {
    outline: none;
    border-color: var(--input-focus-border);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* ========== USER INFO DISPLAY ========== */
.user-info-display {
    margin-bottom: 20px;
}

.info-section {
    margin-bottom: 25px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-section h4 {
    margin: 0 0 20px 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-section h4 i {
    color: var(--accent-color);
    font-size: 18px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-item label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}

.info-item span {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 10px 14px;
    background: var(--input-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    word-break: break-word;
    line-height: 1.4;
    min-height: 20px;
    display: flex;
    align-items: center;
}

.form-input:disabled,
.form-input[readonly] {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border-light);
}

.form-input::placeholder {
    color: var(--input-placeholder);
}

.form-actions {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--status-warning) 0%, #e67e22 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

.license-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.license-item {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.license-item:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-sm);
}

.license-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.license-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive Profile */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 30px 20px;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 40px;
    }
    
    .profile-header-info h3 {
        font-size: 22px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .license-grid {
        grid-template-columns: 1fr;
    }
    
    .profile-section {
        padding: 20px;
    }
}

/* ========== PERMISSION MANAGEMENT SECTION ========== */

/* Permission Header */
.permission-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
    padding: 30px;
    margin-bottom: 0;
    box-shadow: var(--shadow-md);
}

.permission-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.permission-title-section {
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
}

.permission-title-section > i {
    font-size: 48px;
    opacity: 0.9;
}

.permission-title-section h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.permission-title-section p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.95);
}

/* Permission Card */
.permission-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Filter Section */
.permission-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 25px 30px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group label i {
    font-size: 12px;
    color: var(--accent-color);
}

.filter-input,
.filter-select {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
    outline: none;
}

.filter-input:focus,
.filter-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-input::placeholder {
    color: var(--text-muted);
}

/* Table Wrapper */
.permission-table-wrapper {
    overflow-x: auto;
    padding: 30px;
}

/* Permission Table */
.permission-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.permission-table thead {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-hover) 100%);
    position: sticky;
    top: 0;
    z-index: 10;
}

.permission-table thead tr {
    border-bottom: 3px solid var(--accent-color);
}

.permission-table thead th {
    padding: 16px 12px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    text-align: left;
    white-space: nowrap;
}

.permission-table thead th.text-center {
    text-align: center;
}

.permission-table thead th i {
    margin-right: 6px;
    color: var(--accent-color);
    font-size: 14px;
}

.permission-table tbody tr {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.permission-table tbody tr:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.permission-table tbody td {
    padding: 16px 12px;
    color: var(--text-primary);
    vertical-align: middle;
}

.permission-table tbody td.text-center {
    text-align: center;
}

.permission-table tbody td.loading-cell {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 16px;
}

.permission-table tbody td.loading-cell i {
    margin-right: 10px;
    font-size: 18px;
}

/* Role Badge */
.permission-table .badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.permission-table .badge.admin {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.permission-table .badge.user {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

/* License Status Badge */
.permission-table .license-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.permission-table .license-badge.active {
    background-color: rgba(39, 174, 96, 0.15);
    color: var(--status-success);
    border: 1.5px solid var(--status-success);
}

.permission-table .license-badge.disabled {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--status-danger);
    border: 1.5px solid var(--status-danger);
}

.permission-table .license-badge.expired {
    background-color: rgba(243, 156, 18, 0.15);
    color: var(--status-warning);
    border: 1.5px solid var(--status-warning);
}

/* Action Buttons */
.permission-table .action-btn {
    padding: 8px 12px;
    margin: 0 4px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.permission-table .action-btn i {
    font-size: 14px;
}

.permission-table .action-btn.btn-edit {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.permission-table .action-btn.btn-edit:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1f6391 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.permission-table .action-btn.btn-view {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
}

.permission-table .action-btn.btn-view:hover {
    background: linear-gradient(135deg, #229954 0%, #1e8449 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.permission-table .action-btn.btn-license {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.permission-table .action-btn.btn-license:hover {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3);
}

.permission-table .action-btn.btn-delete {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.permission-table .action-btn.btn-delete:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

/* Empty State */
.permission-table tbody .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.permission-table tbody .empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.permission-table tbody .empty-state p {
    font-size: 16px;
    margin: 0;
}

/* Responsive Permission Table */
@media (max-width: 1200px) {
    .permission-filters {
        grid-template-columns: 1fr;
    }
    
    .permission-table-wrapper {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .permission-header {
        padding: 20px;
        border-radius: 12px 12px 0 0;
    }
    
    .permission-title-section {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .permission-title-section > i {
        font-size: 36px;
    }
    
    .permission-title-section h2 {
        font-size: 22px;
    }
    
    .permission-title-section p {
        font-size: 13px;
    }
    
    .permission-card {
        border-radius: 0 0 12px 12px;
    }
    
    .permission-filters {
        padding: 20px;
    }
    
    .permission-table-wrapper {
        padding: 15px;
    }
    
    .permission-table {
        font-size: 12px;
    }
    
    .permission-table thead th {
        padding: 12px 8px;
        font-size: 11px;
    }
    
    .permission-table tbody td {
        padding: 12px 8px;
    }
    
    .permission-table .action-btn {
        padding: 6px 10px;
        font-size: 11px;
        margin: 2px;
    }
    
    .permission-table .action-btn span {
        display: none; /* Hide text on mobile, show only icons */
    }
}

/* Dark Mode Specific Adjustments */
[data-theme="dark"] .permission-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

[data-theme="dark"] .permission-table thead {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #2d2d2d 100%);
}

[data-theme="dark"] .permission-table tbody tr:hover {
    background: var(--bg-hover);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .filter-input:focus,
[data-theme="dark"] .filter-select:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* ========== SELECT & INPUT IMPROVEMENTS ========== */

/* Better select styling */
select {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

select:hover {
    border-color: var(--accent-color);
}

select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

select option {
    background-color: var(--input-bg);
    color: var(--text-primary);
    padding: 8px;
}

/* Input text improvements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder);
}

/* Dark mode improvements for form elements */
[data-theme="dark"] select {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--input-border);
}

[data-theme="dark"] select option {
    background-color: #2d2d2d;
    color: var(--text-primary);
}

[data-theme="dark"] select:hover {
    border-color: var(--accent-color);
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--input-border);
}

/* Better contrast for disabled inputs */
input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    border-color: var(--border-light);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Read-only inputs */
input[readonly] {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: default;
}

