/* ============================================================
   Factory Document System v2 - Design System
   Modern, clean UI with consistent spacing & soft shadows
   ============================================================ */

:root {
    --fds-primary: #3b82f6;
    --fds-primary-dark: #2563eb;
    --fds-primary-light: #eff6ff;
    --fds-accent: #6366f1;
    --fds-success: #10b981;
    --fds-warning: #f59e0b;
    --fds-danger: #ef4444;
    --fds-info: #06b6d4;
    --fds-bg: #f1f5f9;
    --fds-bg-card: #ffffff;
    --fds-bg-subtle: #f8fafc;
    --fds-text: #1e293b;
    --fds-text-secondary: #64748b;
    --fds-text-muted: #94a3b8;
    --fds-border: #e2e8f0;
    --fds-shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --fds-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --fds-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -2px rgba(0, 0, 0, .05);
    --fds-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -4px rgba(0, 0, 0, .04);
    --fds-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .08), 0 8px 10px -6px rgba(0, 0, 0, .04);
    --fds-radius-sm: 6px;
    --fds-radius: 10px;
    --fds-radius-lg: 14px;
    --fds-radius-xl: 20px;
    --fds-nav-bg: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1d4ed8 100%);
    --fds-nav-height: 60px;
    --fds-transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

body {
    background: var(--fds-bg);
    font-family: 'Sarabun', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--fds-text);
    -webkit-font-smoothing: antialiased;
}

main {
    flex: 1;
}

.navbar-fds {
    background: var(--fds-nav-bg);
    min-height: var(--fds-nav-height);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 4px 12px rgba(0, 0, 0, .06);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    padding: 0 1rem;
}

.navbar-fds .navbar-brand {
    font-weight: 700;
    letter-spacing: .3px;
    font-size: 1.15rem;
    color: #fff !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-fds .navbar-brand img {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .2));
}

.navbar-fds .nav-link {
    color: rgba(255, 255, 255, .8) !important;
    font-weight: 500;
    font-size: .9rem;
    padding: .6rem .85rem !important;
    border-radius: var(--fds-radius-sm);
    transition: var(--fds-transition);
}

.navbar-fds .nav-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, .1);
}

.navbar-fds .dropdown-menu {
    border: 1px solid var(--fds-border);
    box-shadow: var(--fds-shadow-lg);
    border-radius: var(--fds-radius);
    padding: .35rem 0;
    margin-top: 4px;
}

.navbar-fds .dropdown-item {
    font-size: .9rem;
    padding: .5rem 1rem;
    transition: var(--fds-transition);
}

.navbar-fds .dropdown-item:hover {
    background: var(--fds-primary-light);
    color: var(--fds-primary-dark);
}

.card {
    border: 1px solid var(--fds-border);
    box-shadow: var(--fds-shadow);
    border-radius: var(--fds-radius-lg);
    background: var(--fds-bg-card);
    transition: var(--fds-transition);
}

.card-header {
    font-weight: 600;
    background: var(--fds-bg-subtle);
    border-bottom: 1px solid var(--fds-border);
    border-radius: var(--fds-radius-lg) var(--fds-radius-lg) 0 0 !important;
    padding: .85rem 1.25rem;
}

.btn {
    border-radius: var(--fds-radius-sm);
    font-weight: 500;
    transition: var(--fds-transition);
    letter-spacing: .01em;
}

.btn:active {
    transform: scale(.97);
}

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

.btn-primary:hover {
    background: var(--fds-primary-dark);
    border-color: var(--fds-primary-dark);
    box-shadow: 0 2px 8px rgba(59, 130, 246, .3);
}

.btn-success {
    background: var(--fds-success);
    border-color: var(--fds-success);
}

.btn-success:hover {
    box-shadow: 0 2px 8px rgba(16, 185, 129, .3);
}

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

.btn-danger:hover {
    box-shadow: 0 2px 8px rgba(239, 68, 68, .3);
}

.btn-outline-primary {
    color: var(--fds-primary);
    border-color: var(--fds-primary);
}

.btn-outline-primary:hover {
    background: var(--fds-primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, .25);
}

.btn-outline-secondary {
    color: var(--fds-text-secondary);
    border-color: var(--fds-border);
}

.btn-outline-secondary:hover {
    background: var(--fds-bg-subtle);
    color: var(--fds-text);
    border-color: #cbd5e1;
}

.table {
    --bs-table-bg: transparent;
    font-size: .9rem;
}

.table th {
    white-space: nowrap;
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--fds-text-secondary);
}

.table>thead {
    border-bottom: 2px solid var(--fds-border);
}

.table>thead.table-dark {
    --bs-table-bg: #1e293b;
    --bs-table-border-color: #334155;
}

.table>thead.table-dark th {
    color: #e2e8f0;
    font-weight: 600;
}

.table-hover>tbody>tr {
    transition: background-color .15s ease;
}

.table-hover>tbody>tr:hover {
    --bs-table-hover-bg: rgba(59, 130, 246, .04);
}

.table td {
    vertical-align: middle;
    padding: .65rem .75rem;
}

.badge {
    font-weight: 600;
    font-size: .78rem;
    padding: .35em .65em;
    border-radius: 999px;
    letter-spacing: .01em;
}

.form-control,
.form-select {
    border-radius: var(--fds-radius-sm);
    border-color: var(--fds-border);
    transition: var(--fds-transition);
    font-size: .9rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--fds-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.form-label {
    font-weight: 500;
    font-size: .88rem;
    color: var(--fds-text);
    margin-bottom: .35rem;
}

.alert {
    border-radius: var(--fds-radius);
    border: none;
    font-size: .9rem;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-left: 4px solid var(--fds-success);
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid var(--fds-danger);
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid var(--fds-warning);
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid var(--fds-primary);
}

.modal-content {
    border: none;
    border-radius: var(--fds-radius-lg);
    box-shadow: var(--fds-shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--fds-border);
    padding: 1rem 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--fds-border);
    padding: .85rem 1.25rem;
}

.pagination .page-link {
    border-radius: var(--fds-radius-sm);
    margin: 0 2px;
    border: 1px solid var(--fds-border);
    color: var(--fds-text-secondary);
    font-size: .85rem;
    transition: var(--fds-transition);
}

.pagination .page-item.active .page-link {
    background: var(--fds-primary);
    border-color: var(--fds-primary);
    color: #fff;
}

.pagination .page-link:hover {
    background: var(--fds-primary-light);
    color: var(--fds-primary);
    border-color: var(--fds-primary);
}

.login-brand {
    color: var(--fds-text);
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -.01em;
}

.btn-login {
    background: var(--fds-nav-bg);
    color: #fff;
    border: none;
    font-weight: 600;
    padding: .6rem 1rem;
    font-size: .95rem;
}

.btn-login:hover {
    background: linear-gradient(135deg, #0c1425 0%, #162d4f 50%, #1843b5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(30, 58, 95, .3);
}

.section-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--fds-text);
    letter-spacing: -.02em;
}

.doc-card {
    transition: transform .2s cubic-bezier(.4, 0, .2, 1), box-shadow .2s cubic-bezier(.4, 0, .2, 1);
    cursor: pointer;
    border-radius: var(--fds-radius-xl) !important;
    min-height: 180px;
    border: 1px solid var(--fds-border) !important;
    overflow: hidden;
    position: relative;
}

.doc-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--fds-shadow-xl) !important;
}

.doc-card.locked-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--fds-shadow-xl) !important;
}

.doc-card.locked-card:hover .doc-lock-badge i {
    animation: lock-shake .5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes lock-shake {
    0% {
        transform: rotate(0deg);
    }

    15% {
        transform: rotate(-20deg);
    }

    30% {
        transform: rotate(20deg);
    }

    45% {
        transform: rotate(-15deg);
    }

    60% {
        transform: rotate(15deg);
    }

    75% {
        transform: rotate(-8deg);
    }

    90% {
        transform: rotate(8deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

.doc-lock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    z-index: 2;
}

.doc-lock-badge.need-login {
    background: #fef9c3;
    color: #a16207;
    border: 1px solid #fde047;
}

.doc-lock-badge.no-perm {
    background: #f1f5f9;
    color: #94a3b8;
    border: 1px solid #cbd5e1;
}

.doc-card .card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 20px;
}

.doc-icon {
    font-size: 2.6rem;
    margin-bottom: 12px;
}

.doc-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 6px;
    color: var(--fds-text);
}

.doc-desc {
    font-size: .82rem;
    color: var(--fds-text-muted);
    line-height: 1.4;
}

.doc-coming-soon {
    font-size: .9rem;
    font-weight: 600;
    color: var(--fds-text-muted);
    letter-spacing: .5px;
    text-transform: uppercase;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h4,
.page-header h5 {
    font-weight: 700;
    color: var(--fds-text);
    margin-bottom: 0;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--fds-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: .75rem;
    opacity: .5;
}

.empty-state-text {
    font-size: 1rem;
    font-weight: 500;
}

footer {
    font-size: 12px;
    color: var(--fds-text-muted);
}

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    main {
        margin-top: 0 !important;
    }
}

@media (max-width: 768px) {
    .table-responsive {
        font-size: .82rem;
    }

    .card-body {
        padding: .75rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-title {
        font-size: 1.4rem;
    }
}