/* ============================================
   SHARED COMPONENT SYSTEM - File Vault
   ============================================
   Reusable UI components for consistent styling
   across all pages. Import after theme.css.
   ============================================ */

/* ============================================
   BASE RESET
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */

/* Page Container */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.page-container--narrow {
    max-width: 800px;
}

.page-container--wide {
    max-width: 1400px;
}

/* Card Component */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 30px;
}

.card--compact {
    padding: 20px;
}

.card--large {
    padding: 40px;
}

/* ============================================
   HEADER COMPONENTS
   ============================================ */

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.page-header__title {
    font-size: 32px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.page-header__subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.logout-form {
    margin: 0;
}

/* ============================================
   BUTTON COMPONENTS
   ============================================ */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button Variants */
.btn--primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn--primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn--secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn--secondary:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--accent);
}

.btn--success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
}

.btn--danger {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
}

.btn--warning {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    color: white;
}

/* Button Sizes */
.btn--sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn--lg {
    padding: 16px 32px;
    font-size: 16px;
}

/* Icon Button */
.btn--icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn--icon-sm {
    width: 36px;
    height: 36px;
}

.btn--icon-lg {
    width: 52px;
    height: 52px;
}

/* Header Chip (Navigation Buttons) */
.header-chip {
    border: none;
    border-radius: 999px;
    padding: 10px 22px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fff;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-glow);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.header-chip:hover,
.header-chip:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.header-chip--theme {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex: 0 0 44px;
    aspect-ratio: 1 / 1;
    font-size: 20px;
    border-radius: 12px;
    justify-content: center;
    color: var(--text-primary);
    letter-spacing: 0;
    text-transform: none;
    gap: 0;
}

.header-chip--theme [data-theme-icon] {
    font-size: 22px;
    line-height: 1;
}

.header-chip--notes {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.header-chip--admin {
    background: linear-gradient(135deg, #7c3aed 0%, #4338ca 100%);
}

.header-chip--back {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.header-chip--home {
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
    padding: 0;
    width: 52px;
    height: 52px;
    min-width: 52px;
    flex: 0 0 52px;
    font-size: 0;
    border-radius: 999px;
    justify-content: center;
    letter-spacing: 0;
    text-transform: none;
}

.header-chip--home [data-home-icon] {
    font-size: 24px;
    line-height: 1;
}

/* ============================================
   FORM COMPONENTS
   ============================================ */

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

.form-group__label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group__hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Input */
.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

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

/* Select */
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-select:focus {
    outline: none;
    border-color: var(--input-focus-border);
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-check__input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* ============================================
   TABLE COMPONENTS
   ============================================ */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

.table th {
    background: var(--table-header-bg);
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
}

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

.table--striped tr:nth-child(even) td {
    background: var(--bg-tertiary);
}

/* ============================================
   BADGE COMPONENTS
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

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

.badge--success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge--warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge--danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge--neutral {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ============================================
   MODAL COMPONENTS
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-bg);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--modal-content-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal--confirm {
    max-width: 400px;
}

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

.modal__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal__close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal__body {
    padding: 24px;
}

.modal__footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   ALERT COMPONENTS
   ============================================ */

.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert__icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert__content {
    flex: 1;
}

.alert__title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert--info {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: var(--accent);
}

.alert--success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.alert--warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.alert--danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ============================================
   TABS COMPONENTS
   ============================================ */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ============================================
   PAGINATION COMPONENTS
   ============================================ */

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination__btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination__btn:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--accent);
}

.pagination__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination__info {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    padding: 0 12px;
}

/* ============================================
   LOADING COMPONENTS
   ============================================ */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner--sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner--lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-elevated) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   ANNOUNCEMENTS
   ============================================ */

.announcements {
    /* `gap` only adds spacing *between* items, not after the last item.
       Add bottom margin so there is consistent space before the next section,
       even when only a single announcement is shown. */
    margin: 14px 0 10px;
    display: grid;
    gap: 10px;
}

.announcement {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}

.announcement__icon {
    font-size: 18px;
    line-height: 1;
    margin-top: 2px;
    flex-shrink: 0;
}

.announcement__content {
    flex: 1;
    min-width: 0;
}

.announcement__title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}

.announcement__message {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

.announcement__close {
    margin-left: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.announcement__close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.announcement--info {
    border-color: rgba(0, 212, 255, 0.35);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.10) 0%, var(--bg-elevated) 100%);
}

.announcement--warning {
    border-color: rgba(245, 158, 11, 0.35);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, var(--bg-elevated) 100%);
}

.announcement--critical {
    border-color: rgba(239, 68, 68, 0.35);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, var(--bg-elevated) 100%);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 450px;
    animation: toast-slide-in 0.3s ease;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast--success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
}

.toast--error {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
}

.toast--warning {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    color: white;
}

.toast--info {
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    color: white;
}

.toast__close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 18px;
}

.toast__close:hover {
    opacity: 1;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Text */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--accent-success); }
.text-warning { color: var(--accent-warning); }
.text-danger { color: var(--accent-danger); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.p-0 { padding: 0; }
.p-8 { padding: 8px; }
.p-16 { padding: 16px; }
.p-24 { padding: 24px; }

/* Flexbox */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

/* Grid */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Display */
.hidden { display: none; }

/* Security Questions modal: avoid inline styles (CSP-safe). */
#questionsModal .error,
#questionsModal .success-msg {
    display: block;
}

#questionsModal .error.hidden,
#questionsModal .success-msg.hidden {
    display: none;
}
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Border Radius */
.rounded { border-radius: var(--radius-md); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 999px; }

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Transitions */
.transition { transition: all 0.2s ease; }
.transition-fast { transition: all 0.15s ease; }
.transition-slow { transition: all 0.3s ease; }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 768px) {
    .page-container {
        padding: 16px;
    }
    
    .card {
        padding: 20px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

