/* ==========================================================================
   Unified Theme - Elegant & Compact
   ========================================================================== */

/* CSS Variables */
:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --accent: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Backgrounds */
    --bg-body: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-surface: #ffffff;
    --bg-muted: #f8fafc;
    --bg-hover: #f1f5f9;
    
    /* Borders */
    --border-color: #e2e8f0;
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.7rem;
    --font-size-sm: 0.8rem;
    --font-size-base: 0.875rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.125rem;
    --font-size-2xl: 1.25rem;
    --line-height: 1.5;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-base); }
h5, h6 { font-size: var(--font-size-sm); }

p {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

small, .small {
    font-size: var(--font-size-sm);
}

.text-muted {
    color: var(--text-muted) !important;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-weight: 600;
    font-size: var(--font-size-lg);
    color: var(--primary) !important;
    display: flex;
    align-items: center;
}

.navbar-brand i {
    font-size: 1.1rem;
}

.nav-link {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary) !important;
    padding: 0.4rem 0.75rem !important;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.08);
}

.nav-link i {
    font-size: var(--font-size-sm);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--font-size-sm);
}

.dropdown-menu {
    font-size: var(--font-size-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.25rem;
}

.dropdown-item {
    font-size: var(--font-size-sm);
    padding: 0.4rem 0.75rem;
    border-radius: calc(var(--border-radius) - 2px);
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.main-content {
    background: var(--bg-surface);
    border-radius: 1rem 1rem 0 0;
    margin-top: 1rem;
    min-height: calc(100vh - 120px);
    box-shadow: var(--shadow-lg);
}

.page-header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: 0;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.card-body {
    padding: 1rem;
}

.card-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0.4rem 0.875rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn i {
    font-size: var(--font-size-sm);
}

.btn-sm {
    font-size: var(--font-size-xs);
    padding: 0.3rem 0.625rem;
}

.btn-lg {
    font-size: var(--font-size-base);
    padding: 0.5rem 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.btn-secondary {
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.btn-outline-primary {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.form-control,
.form-select {
    font-size: var(--font-size-sm);
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control-sm,
.form-select-sm {
    font-size: var(--font-size-xs);
    padding: 0.3rem 0.5rem;
}

.form-text {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.form-check-input {
    width: 1rem;
    height: 1rem;
}

.form-check-label {
    font-size: var(--font-size-sm);
}

/* Form Sections */
.form-section {
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
}

.section-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--primary);
    font-size: var(--font-size-base);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.form-group {
    margin-bottom: 0.75rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
    font-size: var(--font-size-sm);
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-muted);
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
    border-color: var(--border-color);
}

.table-hover tbody tr:hover {
    background: var(--bg-hover);
}

.table-responsive {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    font-size: var(--font-size-xs);
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--border-radius) - 2px);
}

.badge.bg-primary { background: var(--primary) !important; }
.badge.bg-success { background: var(--success) !important; }
.badge.bg-warning { background: var(--warning) !important; }
.badge.bg-danger { background: var(--danger) !important; }
.badge.bg-secondary { background: var(--secondary) !important; }

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    font-size: var(--font-size-sm);
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius);
    border: none;
}

.alert i {
    font-size: var(--font-size-sm);
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-danger, .alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 0;
    margin-top: auto;
}

/* ==========================================================================
   Notification Popup
   ========================================================================== */

.notification-popup {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    max-width: 320px;
    min-width: 280px;
    z-index: 10001;
    display: none;
}

.notification-popup.show {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.notification-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--primary);
}

.notification-content {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.notification-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.notification-password-section input {
    font-size: var(--font-size-sm);
}

.notification-buttons {
    display: flex;
    justify-content: flex-end;
}

/* ==========================================================================
   Grid Cards (for ISO, Landing Page, etc.)
   ========================================================================== */

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.grid-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.grid-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.grid-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.grid-card:hover::before {
    transform: scaleX(1);
}

.grid-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.grid-card-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.grid-card-badge {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: var(--font-size-xs);
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    font-weight: 500;
}

.grid-card-info {
    margin-bottom: 0.75rem;
}

.grid-card-info-item {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    padding: 0.25rem 0;
}

.grid-card-label {
    color: var(--text-muted);
}

.grid-card-value {
    color: var(--text-primary);
    font-weight: 500;
}

.grid-card-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.grid-card-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

.empty-state-icon {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.empty-state-text {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.status-yes, .status-ok {
    background: #d1fae5;
    color: #065f46;
}

.status-no {
    background: #fee2e2;
    color: #991b1b;
}

.status-na {
    background: #fef3c7;
    color: #92400e;
}

/* ==========================================================================
   Detail View
   ========================================================================== */

.detail-section {
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.detail-item {
    background: var(--bg-surface);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.detail-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
}

/* ==========================================================================
   Dashboard Layout - Unified Sidebar Navigation
   ========================================================================== */

.dashboard-layout {
    background: #f1f5f9;
}

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.dashboard-sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: var(--font-size-lg);
}

.sidebar-brand i {
    font-size: 1.25rem;
    color: var(--primary-light);
}

.sidebar-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.nav-section {
    padding: 0.5rem 0;
}

.nav-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 0.5rem 1rem 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    color: #cbd5e1 !important;
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 400;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i {
    font-size: var(--font-size-base);
    width: 1.25rem;
    text-align: center;
    opacity: 0.8;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white !important;
}

.sidebar-nav .nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light) !important;
    border-left-color: var(--primary-light);
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--font-size-sm);
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: var(--font-size-xs);
    color: #64748b;
}

.btn-logout {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Main Content Area */
.dashboard-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Dashboard Header */
.dashboard-header {
    background: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.375rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: none;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
}

.page-info .page-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: 0;
    color: var(--text-primary);
}

.page-info .page-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Dashboard Content */
.dashboard-content {
    flex: 1;
    padding: 1.5rem;
    background: #f1f5f9;
}

/* Dashboard Footer */
.dashboard-footer {
    background: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Responsive Sidebar */
@media (max-width: 991.98px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
    }
    
    .dashboard-sidebar.show {
        transform: translateX(0);
    }
    
    .dashboard-main {
        margin-left: 0;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    /* Overlay when sidebar is open */
    .dashboard-sidebar.show::after {
        content: '';
        position: fixed;
        top: 0;
        left: 240px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: -1;
    }
}

/* ==========================================================================
   Animations
   ========================================================================== */

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        --font-size-base: 0.8125rem;
    }
    
    .main-content {
        border-radius: 0.75rem 0.75rem 0 0;
        margin-top: 0.5rem;
    }
    
    .page-title {
        font-size: var(--font-size-lg);
    }
    
    .grid-cards {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        margin-left: -220px;
    }
    
    .sidebar.show {
        margin-left: 0;
    }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }

.bg-gradient {
    background: var(--bg-body);
}

.rounded-lg {
    border-radius: var(--border-radius-lg) !important;
}

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
