:root {
    --primary-color: #00C853;
    --primary-hover: #00E676;
    --secondary-color: #121212;
    --accent-color: #00E676;
    --bg-dark: #0a0a0a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-glass: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #ffffff;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --btn-close-filter: invert(1);
    --dropdown-bg: rgba(20, 20, 20, 0.95);
    --list-group-hover: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
    --secondary-color: #ffffff;
    --bg-dark: #f5f5f5;
    --bg-card: rgba(0, 0, 0, 0.03);
    --bg-glass: rgba(255, 255, 255, 0.9);
    --border-glass: rgba(0, 0, 0, 0.1);
    --text-primary: #121212;
    --text-secondary: #555555;
    --text-muted: #999999;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --btn-close-filter: invert(0);
    --dropdown-bg: rgba(255, 255, 255, 0.98);
    --list-group-hover: rgba(0, 0, 0, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-dark);
    padding: 20px;
}

[data-theme="dark"] .auth-page {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0d0d0d 100%);
}

[data-theme="light"] .auth-page {
    background: linear-gradient(135deg, #e8f5e9 0%, #f5f5f5 50%, #e8f5e9 100%);
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #000;
    box-shadow: 0 0 30px rgba(0, 200, 83, 0.3);
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.auth-body .form-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 12px 16px;
    height: auto;
    border-radius: var(--radius-sm);
}

.auth-body .form-control:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 200, 83, 0.15);
    color: var(--text-primary);
}

.auth-body .form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

[data-theme="light"] .auth-body .form-control {
    background: rgba(0, 0, 0, 0.03);
}

.auth-body .form-label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.auth-body .form-label i {
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    color: #000;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 200, 83, 0.4);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #000;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-glass);
}

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

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i {
    font-size: 1.75rem;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    text-decoration: none;
}

.sidebar-nav .nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .sidebar-nav .nav-link:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sidebar-nav .nav-link.active {
    color: var(--primary-color);
    background: rgba(0, 200, 83, 0.1);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.sidebar-divider {
    border-color: var(--border-glass);
    margin: 8px 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    background: var(--bg-dark);
}

[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 260px;
}

/* Topbar */
.topbar {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 8px 24px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.sidebar-toggle-btn {
    color: var(--text-secondary);
    font-size: 1.5rem;
    padding: 4px;
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.glass-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-glass);
    padding: 16px 20px;
}

.glass-card .card-body {
    padding: 20px;
}

/* Stat Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.bg-primary-glow {
    background: rgba(0, 200, 83, 0.15);
    color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 200, 83, 0.15);
}

.bg-success-glow {
    background: rgba(0, 230, 118, 0.15);
    color: var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.15);
}

.bg-info-glow {
    background: rgba(13, 202, 240, 0.15);
    color: #0dcaf0;
    box-shadow: 0 0 20px rgba(13, 202, 240, 0.15);
}

.bg-warning-glow {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.15);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stat-label {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
}

/* Service Icon */
.service-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* TOTP Code Display */
.totp-code-display {
    font-family: 'Courier New', monospace;
    letter-spacing: 4px;
    color: var(--primary-color);
}

.totp-timer .progress-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 4px;
}

/* Avatar */
.avatar-circle {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: #000;
    font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 0.875rem;
}

.avatar-xl {
    width: 100px;
    height: 100px;
    font-size: 2rem;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Theme Options */
.theme-option {
    width: 100px;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-glass);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.theme-option:hover {
    border-color: var(--primary-color);
}

.theme-option.active {
    border-color: var(--primary-color);
    background: rgba(0, 200, 83, 0.1);
}

.theme-option i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 4px;
}

.theme-option span {
    font-size: 0.875rem;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

[dir="rtl"] .timeline {
    padding-left: 0;
    padding-right: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-glass);
}

[dir="rtl"] .timeline::before {
    left: auto;
    right: 7px;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
    padding-left: 16px;
}

[dir="rtl"] .timeline-item {
    padding-left: 0;
    padding-right: 16px;
}

.timeline-icon {
    position: absolute;
    left: -24px;
    top: 4px;
    color: var(--primary-color);
    font-size: 0.75rem;
}

[dir="rtl"] .timeline-icon {
    left: auto;
    right: -24px;
}

.timeline-content p {
    margin: 0;
}

/* Folder Card */
.folder-card {
    transition: var(--transition);
}

.folder-card:hover {
    transform: translateY(-4px);
}

/* Table Styles */
.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table > thead {
    border-bottom: 2px solid var(--border-glass);
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--border-glass);
    background: transparent;
}

.table-hover > tbody > tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .table-hover > tbody > tr:hover {
    background: rgba(0, 0, 0, 0.03);
}

/* Form Controls */
.form-control, .form-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 200, 83, 0.15);
    color: var(--text-primary);
}

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

.form-control-color {
    padding: 4px;
    cursor: pointer;
}

/* Ensure labels, headings, card headers, and empty state text use primary text color */
.form-label,
.card-header,
.card-header h5,
.card-header h4,
.card-header h3,
.empty-state h4,
.empty-state h5,
.empty-state p,
.empty-state i,
.empty-state .bi {
    color: var(--text-primary) !important;
}

/* Disabled form control styling for dark mode */
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control[readonly] {
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-muted);
}

/* Table text color in dark mode */
[data-theme="dark"] .table,
[data-theme="dark"] .table > :not(caption) > * > * {
    --bs-table-color: var(--text-primary);
    color: var(--text-primary) !important;
}

/* Admin/Profile info text */
.small strong,
.profile-details p,
.profile-details strong {
    color: inherit;
}

/* Timeline text */
.timeline-content p {
    color: var(--text-primary);
}

/* Select option styling for dark theme */
.form-select option {
    background: #1a1a1a;
    color: #ffffff;
}

[data-theme="light"] .form-select option {
    background: #ffffff;
    color: #121212;
}

/* Badge Styles */
.badge {
    padding: 6px 12px;
    font-weight: 500;
}

/* Modal Glass */
.modal-content.glass-card {
    border: 1px solid var(--border-glass);
}

.modal-header {
    border-bottom-color: var(--border-glass);
    color: var(--text-primary);
}

.modal-body {
    color: var(--text-primary);
}

.modal-footer {
    border-top-color: var(--border-glass);
}

.btn-close {
    filter: var(--btn-close-filter);
}

/* Dropdown */
.dropdown-menu {
    background: var(--dropdown-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow);
}

.dropdown-item {
    color: var(--text-primary);
    transition: var(--transition);
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

[data-theme="light"] .dropdown-item:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #121212;
}

.dropdown-header {
    color: var(--text-secondary);
}

.dropdown-divider {
    border-color: var(--border-glass);
}

.dropdown-item.text-danger {
    color: #dc3545 !important;
}

.dropdown-item.text-danger:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545 !important;
}

.dropdown-item.text-warning {
    color: #ffc107 !important;
}

/* Pagination */
.pagination {
    margin-top: 16px;
}

.page-link {
    background: var(--bg-card);
    border-color: var(--border-glass);
    color: var(--text-primary);
    transition: var(--transition);
}

.page-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-glass);
    color: var(--primary-color);
}

[data-theme="light"] .page-link:hover {
    background: rgba(0, 0, 0, 0.06);
}

.page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #000;
}

.page-item.disabled .page-link {
    background: transparent;
    border-color: var(--border-glass);
    color: var(--text-muted);
}

/* List Group */
.list-group-item {
    color: var(--text-primary);
}

.list-group-item.bg-transparent:hover {
    background: var(--list-group-hover) !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    [dir="rtl"] .main-content {
        margin-right: 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card, .folder-card {
    animation: fadeIn 0.4s ease-out;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 200, 83, 0.15); }
    50% { box-shadow: 0 0 40px rgba(0, 200, 83, 0.3); }
}

.totp-code-display {
    animation: pulse-glow 2s infinite;
}

/* Alert Styles */
.alert {
    border: none;
    border-radius: var(--radius-sm);
}

.alert-success {
    background: rgba(0, 200, 83, 0.15);
    color: var(--primary-color);
}

.alert-danger {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.alert-info {
    background: rgba(13, 202, 240, 0.15);
    color: #0dcaf0;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

/* Break long words */
.break-all {
    word-break: break-all;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: 20px;
}

.toast-notification {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.3s ease-out;
    min-width: 300px;
}

/* RTL General Utilities */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

[dir="rtl"] .me-1,
[dir="rtl"] .me-2,
[dir="rtl"] .me-3 {
    margin-right: 0 !important;
    margin-left: 0.25rem !important;
}

[dir="rtl"] .me-2 { margin-left: 0.5rem !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; }

[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }

[dir="rtl"] .dropdown-menu-end {
    right: auto;
    left: 0;
}

[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }

[dir="rtl"] .input-group > .form-control:not(:last-child) {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

[dir="rtl"] .input-group > .btn:not(:first-child) {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

[dir="rtl"] .input-group > .form-control:not(:first-child) {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

[dir="rtl"] .input-group > .btn:not(:last-child) {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
