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

:root {
    --primary: #0366d6;
    --primary-hover: #0256b9;
    --secondary: #6c757d;
    --secondary-hover: #5a6268;
    --danger: #dc3545;
    --danger-hover: #c82333;
    --success: #28a745;
    --warning: #ffc107;
    --bg: #f8f9fa;
    --bg-white: #ffffff;
    --text: #212529;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* === Navigation === */
.navbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-links span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-links a:hover {
    color: var(--primary);
}

/* === Main Content === */
.main-content {
    flex: 1;
    padding: 30px 0;
}

/* === Admin Tabs === */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-white);
    padding: 6px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    width: fit-content;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-btn svg {
    width: 16px;
    height: 16px;
}

.tab-content {
    display: none;
}

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

/* === Admin Stats Cards === */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-primary {
    background: rgba(3, 102, 214, 0.1);
    color: var(--primary);
}

.stat-icon-success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.stat-icon-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #d4a000;
}

.stat-icon-danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.stat-info p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Admin Sections === */
.admin-section {
    margin-top: 24px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.form-group-action {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0;
}

/* === Footer === */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: auto;
}

/* === Version Badge === */
.version-badge {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-left: 4px;
}

/* === Alerts === */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.alert-close:hover {
    opacity: 1;
}

/* === Auth Pages === */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.auth-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    text-align: center;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.auth-footer a:hover {
    text-decoration: underline;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.15);
}

.form-hint {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

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

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

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

.btn-secondary:hover {
    background: var(--secondary-hover);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* === Upload Section === */
.upload-section {
    margin-bottom: 24px;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: #e7f1ff;
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.drop-zone p {
    margin-bottom: 8px;
    color: var(--text-muted);
}

.upload-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

.drop-zone small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.upload-progress {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
    box-shadow: var(--shadow);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
    border-radius: 4px;
}

.upload-progress p {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* === Search Bar === */
.search-bar {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* === File List === */
.file-table {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.file-table th {
    background: var(--bg);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.file-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.file-table tr:last-child td {
    border-bottom: none;
}

.file-table tr:hover {
    background: #f8f9ff;
}

.file-name {
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--text-muted);
    white-space: nowrap;
}

.file-uploader {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.file-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.file-count {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--border);
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* === Error Page === */
.error-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.error-card {
    text-align: center;
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.error-icon {
    width: 64px;
    height: 64px;
    color: var(--danger);
    margin-bottom: 16px;
}

.error-card h2 {
    margin-bottom: 12px;
}

.error-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* === Modals === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

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

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-header h2 {
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.share-filename {
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text);
}

.share-form .form-row {
    margin-bottom: 20px;
}

.share-result {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
}

.share-result p {
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.share-url-container {
    display: flex;
    gap: 8px;
}

.share-url-container input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.text-warning {
    color: var(--warning);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .auth-card {
        padding: 24px;
    }
    
    .drop-zone {
        padding: 30px 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .file-table {
        overflow-x: auto;
    }
    
    .file-actions {
        flex-direction: column;
    }
    
    .file-actions .btn-sm {
        width: 100%;
        text-align: center;
    }
    
    .search-form {
        flex-direction: column;
    }
}

/* === Role Badges === */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    background: #dc3545;
    color: white;
}

.role-user {
    background: #0366d6;
    color: white;
}

.role-guest {
    background: #6c757d;
    color: white;
}

.admin-link {
    color: #dc3545;
    font-weight: 600;
}

.admin-link:hover {
    text-decoration: underline;
}

/* === Guest Notice === */
.guest-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

/* === User Management Section === */
.user-management-section {
    margin-top: 40px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

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

.section-header h2 {
    font-size: 1.3rem;
    color: var(--text);
}

.create-user-form {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

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

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

.users-table th,
.users-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.username-cell {
    font-weight: 500;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.text-warning {
    color: #856404;
    font-size: 0.9rem;
    margin-top: 8px;
}

/* === File Access Column === */
.file-access {
    min-width: 120px;
}

.view-access-btn {
    background: #17a2b8;
    color: white;
}

.view-access-btn:hover {
    background: #138496;
}

/* === Access Modal === */
.modal-large {
    max-width: 700px;
}

.access-list {
    margin: 16px 0;
}

.access-list h3 {
    margin-bottom: 12px;
    color: var(--text);
}

.access-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.access-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.access-username {
    font-weight: 500;
    flex: 1;
}

.access-type {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.access-type.owner {
    background: #28a745;
    color: white;
}

.access-type.shared {
    background: #0366d6;
    color: white;
}

#share-with-user-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

#share-with-user-section h3 {
    margin-bottom: 12px;
    color: var(--text);
}

.empty-text {
    color: var(--text-muted);
    font-style: italic;
}

.error-text {
    color: #dc3545;
    font-style: italic;
}

.share-filename {
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

/* === Activity Section === */
.activity-section {
    margin-top: 30px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.activity-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.activity-section .section-header h2 {
    font-size: 1.3rem;
    color: var(--text);
}

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

.activity-list thead th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.activity-list tbody tr {
    border-bottom: 1px solid var(--border);
}

.activity-list tbody tr:last-child {
    border-bottom: none;
}

.activity-list tbody td {
    padding: 10px 12px;
    font-size: 0.9rem;
}

.activity-time {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 150px;
}

.activity-user {
    font-weight: 500;
    min-width: 100px;
}

.action-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.action-LOGIN {
    background: #d4edda;
    color: #155724;
}

.action-UPLOAD {
    background: #cce5ff;
    color: #004085;
}

.action-DOWNLOAD {
    background: #fff3cd;
    color: #856404;
}

.action-DELETE {
    background: #f8d7da;
    color: #721c24;
}

.action-CREATE_SHARE_LINK {
    background: #e2e3e5;
    color: #383d41;
}

.action-GRANT_ACCESS {
    background: #d1ecf1;
    color: #0c5460;
}

.action-REVOKE_ACCESS {
    background: #f5c6cb;
    color: #721c24;
}

.activity-details {
    color: var(--text);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.refresh-logs-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
}

.refresh-logs-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

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