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

:root {
    --bg-primary: #0a0f1d;
    --bg-secondary: #121829;
    --card-bg: rgba(30, 41, 59, 0.4);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --gradient-accent: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-danger: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --shadow-neon: 0 0 20px rgba(6, 182, 212, 0.25);
    --font-family: 'Outfit', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background: radial-gradient(circle at 50% 0%, #1e293b 0%, var(--bg-primary) 70%);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex-grow: 1;
}

/* Header & Navigation */
header {
    background: rgba(10, 15, 29, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

.logo span {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-user-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.nav-user-info strong {
    color: var(--accent-cyan);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: var(--gradient-accent);
    color: #020617;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.2);
}

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

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Glassmorphism Card */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    margin-bottom: 2rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    margin-bottom: 1rem;
}

.hero h1 {
    font-size: 2.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
}

.hero h1 span {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.15rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Login/Change Password Page Center Card */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 450px;
}

.auth-card h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
}

.auth-card p.subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

.alert-danger {
    background: rgba(244, 63, 94, 0.15);
    color: #f87171;
    border-color: rgba(244, 63, 94, 0.3);
}

/* Search and Filters */
.search-bar-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input-wrapper {
    flex-grow: 1;
    position: relative;
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.85rem 1.25rem;
    padding-left: 3rem;
    background: rgba(30, 41, 59, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.05rem;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: var(--shadow-neon);
}

.search-icon {
    position: absolute;
    left: 1.15rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Tab Styles */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 2rem;
    gap: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    font-family: var(--font-family);
}

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

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

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-accent);
    border-radius: 3px 3px 0 0;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

/* Document Grid */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.doc-card {
    background: rgba(30, 41, 59, 0.25);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
}

.doc-card:hover {
    transform: translateY(-5px);
    border-color: rgba(6, 182, 212, 0.4);
    background: rgba(30, 41, 59, 0.4);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.doc-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.doc-badge {
    display: inline-block;
    white-space: nowrap;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-public {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-private {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.doc-category {
    display: inline-block;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.doc-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    color: var(--text-primary);
}

.doc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.doc-size {
    font-style: italic;
}

.doc-actions {
    display: flex;
    gap: 0.5rem;
}

/* Admin Grid Layout */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 992px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

/* Drag & Drop Upload Uploader Box */
.upload-zone {
    border: 2px dashed rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(15, 23, 42, 0.4);
    margin-bottom: 1.5rem;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.05);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--accent-cyan);
    margin-bottom: 1rem;
}

.upload-text {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* User Management Panel */
.user-list {
    margin-top: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.4);
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border);
}

.user-item:last-child {
    border-bottom: none;
}

.user-name {
    font-weight: 500;
}

.user-role {
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    border-radius: 12px;
    font-weight: 600;
}

.role-admin {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.role-user {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
}

/* Document Table (Alternate list style) */
.doc-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.4);
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.doc-table th {
    background: rgba(30, 41, 59, 0.6);
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
}

.doc-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.95rem;
}

.doc-table th, .doc-table td {
    vertical-align: middle;
}

/* ป้องกันคอลัมน์ข้อมูลเมทาดาตาหดหรือตัดบรรทัด ปล่อยให้ยาวพอดีและเลื่อนแนวนอนหากหน้าจอเล็กมาก */
.doc-table th:not(:first-child),
.doc-table td:not(:first-child) {
    white-space: nowrap;
}

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

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

/* Footer styling */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--card-border);
    margin-top: 4rem;
}

/* Modal and Temporary Password Alert box */
.temp-pwd-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.temp-pwd-value {
    font-family: monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: #fbbf24;
    letter-spacing: 2px;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    display: inline-block;
}

/* Empty State styling */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

.text-cyan {
    color: var(--accent-cyan) !important;
}

/* Loading display for async operations */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-cyan);
    animation: spin 1s ease-in-out infinite;
}

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