/* -------------------------------------------------------------
 * CSS Custom Properties & Base Setup (Design System)
 * ------------------------------------------------------------- */
:root {
    /* Color Palette */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --bg-main: #0b0f19;
    --card-bg: rgba(30, 41, 59, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-border: rgba(16, 185, 129, 0.3);

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-border: rgba(239, 68, 68, 0.3);

    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    
    --border: rgba(255, 255, 255, 0.1);
    
    /* Layout */
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    
    --font-sans: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-main);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.6;
}

/* -------------------------------------------------------------
 * Layout & Navigation
 * ------------------------------------------------------------- */
.app-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: 0.5px;
    user-select: none;
}

.logo .accent {
    color: var(--primary);
    position: relative;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px 6px 6px;
    border-radius: 50px;
    border: 1px solid var(--card-border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    box-shadow: 0 0 10px var(--primary-glow);
}

.user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.1;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.logout-btn {
    opacity: 0.85;
}
.logout-btn:hover {
    opacity: 1;
}

/* -------------------------------------------------------------
 * Main Workspace Layout
 * ------------------------------------------------------------- */
.app-main {
    flex: 1;
    background: var(--bg-gradient);
    padding: 40px 24px;
}

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* -------------------------------------------------------------
 * Cards (Shared Component)
 * ------------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition);
}

.card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.section-header h2 {
    margin-bottom: 0;
}

/* -------------------------------------------------------------
 * Upload Section
 * ------------------------------------------------------------- */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: var(--transition);
    user-select: none;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: inset 0 0 15px rgba(99, 102, 241, 0.05);
}

.drop-zone-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 14px;
    transition: transform 0.3s ease;
}

.drop-zone:hover .drop-zone-icon {
    transform: translateY(-5px);
}

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

.drop-zone-prompt span {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

.file-input {
    display: none;
}

.file-info-preview {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.file-info-preview .file-icon {
    font-size: 1.4rem;
    margin-right: 12px;
}

.file-info-preview .file-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.file-info-preview .file-size {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-right: 15px;
}

.btn-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-clear:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

#btn-upload {
    margin-top: 16px;
}

/* -------------------------------------------------------------
 * Files & Users Table
 * ------------------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.files-table, .users-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.files-table th, .users-table th {
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.files-table td, .users-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.files-table tr:last-child td, .users-table tr:last-child td {
    border-bottom: none;
}

.files-table tr:hover td, .users-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.file-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    transition: var(--transition);
    max-width: 100%;
}

.file-link:hover {
    color: var(--primary);
}

.file-link:hover .file-name-text {
    text-decoration: underline;
}

.file-icon {
    font-size: 1.3rem;
}

.file-name-text {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
    display: inline-block;
}

.date-cell {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.action-cell {
    white-space: nowrap;
}

.inline-form {
    display: inline-block;
    margin-left: 8px;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
}

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

/* -------------------------------------------------------------
 * Buttons & Forms
 * ------------------------------------------------------------- */
.btn {
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.btn-success:hover {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    font-weight: 600;
}

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

.text-right { text-align: right; }
.hidden { display: none !important; }

/* -------------------------------------------------------------
 * Login Interface (Special Layout)
 * ------------------------------------------------------------- */
.login-body {
    background: var(--bg-gradient);
    justify-content: center;
    align-items: center;
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-card {
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo {
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.login-header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms General */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}


input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
}

/* -------------------------------------------------------------
 * Notifications & Badges
 * ------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.alert-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* Badges */
.badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-role {
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-admin {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-viewer {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Grid Utilities */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 28px;
    align-items: start;
}

/* -------------------------------------------------------------
 * Footer
 * ------------------------------------------------------------- */
.app-footer {
    padding: 24px;
    text-align: center;
    border-top: 1px solid var(--card-border);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-dark);
    font-size: 0.8rem;
}

/* -------------------------------------------------------------
 * Animations
 * ------------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

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

.animate-fade-in {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* -------------------------------------------------------------
 * Responsive Media Queries
 * ------------------------------------------------------------- */
@media (max-width: 820px) {
    .grid-2col {
        grid-template-columns: 1fr;
    }
    
    .header-container {
        flex-direction: column;
        gap: 16px;
    }
    
    .header-nav {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .btn-text {
        display: none;
    }
    
    .btn-icon {
        padding: 8px;
    }
    
    .app-main {
        padding: 20px 12px;
    }
    
    .card {
        padding: 20px;
    }
    
    .files-table td, .files-table th {
        padding: 10px 8px;
    }
}
