/* ============================= */
/* Cupertino Cloud - Modern UI   */
/* Apple/Google Design Standards */
/* ============================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* ============================= */
/* CSS Custom Properties         */
/* ============================= */
:root {
    /* Colors - Refined Apple-inspired palette */
    --color-bg-primary: #f5f5f7;
    --color-bg-secondary: #ffffff;
    --color-bg-elevated: rgba(255, 255, 255, 0.72);
    --color-bg-glass: rgba(255, 255, 255, 0.65);

    --color-text-primary: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-text-tertiary: #86868b;

    --color-accent: #0071e3;
    --color-accent-hover: #0077ed;
    --color-accent-light: rgba(0, 113, 227, 0.08);

    --color-success: #34c759;
    --color-warning: #ff9f0a;
    --color-danger: #ff3b30;
    --color-danger-light: rgba(255, 59, 48, 0.1);

    --color-border: rgba(0, 0, 0, 0.06);
    --color-border-strong: rgba(0, 0, 0, 0.12);

    /* Shadows - Layered depth */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 24px 80px rgba(0, 0, 0, 0.16);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Sidebar */
    --sidebar-width: 280px;
}

/* ============================= */
/* Reset & Base                  */
/* ============================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    min-height: 100vh;
    display: flex;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

/* Subtle grid pattern background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(0,0,0,0.03) 1px, transparent 0);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: -1;
}

/* ============================= */
/* Typography                    */
/* ============================= */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--color-text-primary);
    margin-bottom: var(--space-lg);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--color-text-primary);
    margin-bottom: var(--space-md);
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-text-primary);
}

p {
    color: var(--color-text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

/* ============================= */
/* Sidebar                       */
/* ============================= */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--color-bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid var(--color-border);
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    z-index: 100;
    animation: slideInLeft 0.4s var(--transition-bounce);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(180deg, rgba(0, 113, 227, 0.05) 0%, transparent 100%);
    pointer-events: none;
}

.sidebar .menu {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    position: relative;
}

.sidebar .menu h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-md);
    padding-left: var(--space-md);
}

/* Sidebar Brand/Logo Area */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding-bottom: var(--space-xl);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-accent) 0%, #5856d6 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: var(--shadow-md);
}

.sidebar-brand-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

/* Sidebar Buttons */
.sidebar .btn {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    padding: var(--space-md) var(--space-md);
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.sidebar .btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-accent);
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: inherit;
}

.sidebar .btn:hover {
    color: var(--color-accent);
    background: var(--color-accent-light);
}

.sidebar .btn:hover::before {
    opacity: 0.04;
}

.sidebar .btn:active {
    transform: scale(0.98);
}

.sidebar .btn i,
.sidebar .btn .btn-icon {
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.sidebar .btn span {
    position: relative;
    z-index: 1;
}

/* Primary Action Button */
.sidebar .btn-primary {
    background: var(--color-accent);
    color: white;
    margin-top: var(--space-sm);
}

.sidebar .btn-primary:hover {
    background: var(--color-accent-hover);
    color: white;
    box-shadow: var(--shadow-md);
}

/* Logout Button */
.sidebar .logout-btn {
    margin-top: auto;
    color: var(--color-danger);
}

.sidebar .logout-btn:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

/* ============================= */
/* Main Content                  */
/* ============================= */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: var(--space-3xl) var(--space-2xl);
    max-width: 1400px;
    animation: fadeInUp 0.5s var(--transition-bounce);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page Header */
.page-header {
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-header h1::before {
    content: '';
    width: 4px;
    height: 32px;
    background: linear-gradient(180deg, var(--color-accent) 0%, #5856d6 100%);
    border-radius: var(--radius-full);
}

/* ============================= */
/* Cards                         */
/* ============================= */
.card {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-base);
}

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

.card-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-primary);
}

.card-body {
    padding: var(--space-xl);
}

/* ============================= */
/* Tables                        */
/* ============================= */
.table-container {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

thead {
    background: linear-gradient(180deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
}

th {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-tertiary);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

td {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.9375rem;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--color-accent-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Client name link in table */
td a {
    font-weight: 500;
    color: var(--color-accent);
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

td a:hover {
    text-decoration: underline;
}

/* Table Action Buttons */
.table-actions {
    display: flex;
    gap: var(--space-sm);
}

.table-actions .btn-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.table-actions .btn-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.table-actions .btn-action i {
    font-size: 0.875rem;
}

.table-actions .edit-btn:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
}

.table-actions .edit-btn i {
    color: var(--color-accent);
}

.table-actions .delete-btn:hover {
    background: var(--color-danger-light);
    border-color: var(--color-danger);
}

.table-actions .delete-btn i {
    color: var(--color-danger);
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--color-bg-primary);
    color: var(--color-text-secondary);
}

.badge-success {
    background: rgba(52, 199, 89, 0.12);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(255, 159, 10, 0.12);
    color: var(--color-warning);
}

/* ============================= */
/* Forms                         */
/* ============================= */
form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.form-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: var(--space-xl);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: var(--space-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--color-text-primary);
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-light);
    background: var(--color-bg-secondary);
}

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

textarea {
    resize: vertical;
    min-height: 100px;
}

.error {
    color: var(--color-danger);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
}

/* ============================= */
/* Buttons                       */
/* ============================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}

.btn:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

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

.btn-secondary:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-text-tertiary);
}

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

.btn-danger:hover {
    background: #e0342b;
}

.btn-ghost {
    background: transparent;
    color: var(--color-accent);
}

.btn-ghost:hover {
    background: var(--color-accent-light);
}

/* ============================= */
/* Modals                        */
/* ============================= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--space-xl);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--color-bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s var(--transition-bounce);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    padding-right: var(--space-xl);
}

.close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-text-tertiary);
    background: var(--color-bg-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1;
}

.close:hover {
    background: var(--color-border-strong);
    color: var(--color-text-primary);
}

/* ============================= */
/* Auth Page Specific            */
/* ============================= */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-xl);
    text-align: center;
}

.auth-container .form-container {
    animation: modalSlideIn 0.5s var(--transition-bounce);
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--color-accent) 0%, #5856d6 100%);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-lg);
}

.auth-logo i {
    font-size: 2.5rem;
    color: white;
}

.auth-title {
    font-size: 1.75rem;
    margin-bottom: var(--space-sm);
}

.auth-subtitle {
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-xl);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
    color: var(--color-text-tertiary);
    font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* ============================= */
/* File Preview Overlay          */
/* ============================= */
.preview-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--space-xl);
}

.preview-content {
    background: var(--color-bg-secondary);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    text-align: center;
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: var(--shadow-xl);
}

.preview-media {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-md);
}

.close-preview {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.close-preview:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* ============================= */
/* Empty States                  */
/* ============================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    background: var(--color-bg-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.empty-state-icon i {
    font-size: 2rem;
    color: var(--color-text-tertiary);
}

.empty-state h3 {
    margin-bottom: var(--space-sm);
}

.empty-state p {
    max-width: 300px;
}

/* ============================= */
/* Utility Classes               */
/* ============================= */
.hidden {
    display: none !important;
    visibility: hidden;
    height: 0;
    padding: 0;
    margin: 0;
}

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

.text-muted {
    color: var(--color-text-tertiary);
}

.mt-auto {
    margin-top: auto;
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

/* ============================= */
/* Responsive                    */
/* ============================= */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }

    .main-content {
        padding: var(--space-xl);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

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

    .main-content {
        margin-left: 0;
        padding: var(--space-lg);
    }

    h1 {
        font-size: 1.75rem;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }
}

/* ============================= */
/* Scrollbar Styling             */
/* ============================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: var(--radius-full);
}

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

/* ============================= */
/* Loading States                */
/* ============================= */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-primary) 25%,
        var(--color-bg-secondary) 50%,
        var(--color-bg-primary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

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

/* ============================= */
/* Success/Error Messages        */
/* ============================= */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.alert-success {
    background: rgba(52, 199, 89, 0.12);
    color: var(--color-success);
    border: 1px solid rgba(52, 199, 89, 0.24);
}

.alert-error {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(255, 59, 48, 0.24);
}

.alert i {
    font-size: 1.25rem;
}

/* ============================= */
/* File Cards (Alternative View) */
/* ============================= */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.file-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
}

.file-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.file-card-icon {
    width: 48px;
    height: 48px;
    background: var(--color-accent-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
}

.file-card-icon i {
    font-size: 1.5rem;
    color: var(--color-accent);
}

.file-card-name {
    font-weight: 600;
    margin-bottom: var(--space-xs);
    word-break: break-word;
}

.file-card-meta {
    font-size: 0.875rem;
    color: var(--color-text-tertiary);
}

.file-card-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
}
