/* ============================================================
   ระบบเกษียนหนังสือราชการด้วยการประทับตรา
   Custom CSS - Animations & Effects
   ============================================================ */

/* ── Base ─────────────────────────────────────── */
* { font-family: 'Sarabun', sans-serif; }
body { background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%); min-height: 100vh; }

/* ── Glassmorphism ────────────────────────────── */
.glass {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 1rem;
}
.glass-light {
    background: rgba(51, 65, 85, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 0.75rem;
}
.glass-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-radius: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.glass-card:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(148, 163, 184, 0.08);
    transition: width 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 4px; }

.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; border-radius: 0.75rem;
    color: #94a3b8;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.95rem;
}
.sidebar-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #c7d2fe;
    transform: translateX(4px);
}
.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.15));
    color: #c7d2fe;
    border-left: 3px solid #6366f1;
}

/* ── Stamp Styles ─────────────────────────────── */
.stamp-card {
    position: relative;
    cursor: pointer;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.stamp-card::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.05), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.stamp-card:hover::before { opacity: 1; }
.stamp-card:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.stamp-card.selected {
    border-color: currentColor;
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

/* ── Receipt Stamp (ตรารับหนังสือ) ────────────── */
.receipt-stamp {
    border: 3px solid #1a47b8;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    color: #1a47b8;
    font-weight: 600;
    position: relative;
    background: rgba(26, 71, 184, 0.05);
    transform: rotate(-2deg);
}
.receipt-stamp::after {
    content: '';
    position: absolute; inset: 3px;
    border: 1px solid rgba(26, 71, 184, 0.4);
    border-radius: 2px;
}

/* ── Stamp Animation ──────────────────────────── */
@keyframes stampPress {
    0% { transform: scale(3) rotate(-15deg); opacity: 0; }
    50% { transform: scale(0.9) rotate(2deg); opacity: 0.9; }
    70% { transform: scale(1.1) rotate(-1deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes stampInk {
    0% { transform: scale(0); opacity: 0.6; }
    50% { transform: scale(1.5); opacity: 0.3; }
    100% { transform: scale(2); opacity: 0; }
}
@keyframes stampShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px) rotate(-1deg); }
    75% { transform: translateX(3px) rotate(1deg); }
}
.stamp-animate {
    animation: stampPress 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}
.stamp-ink-effect {
    position: absolute;
    width: 100px; height: 100px;
    border-radius: 50%;
    animation: stampInk 0.8s ease-out forwards;
    pointer-events: none;
}
.stamp-shake {
    animation: stampShake 0.3s ease-in-out;
}

/* ── Endorsement Stamp Display ────────────────── */
.endorsement-stamp {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border: 2px solid;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    position: relative;
}
.endorsement-stamp::before {
    content: '';
    position: absolute; inset: 2px;
    border: 1px solid;
    border-radius: 9999px;
    opacity: 0.3;
}

/* ── Timeline ─────────────────────────────────── */
.timeline-item {
    position: relative;
    padding-left: 2.5rem;
    padding-bottom: 2rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 2rem;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.3), transparent);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    position: absolute;
    left: 0;
    top: 0.25rem;
    width: 1.75rem; height: 1.75rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    border: 2px solid;
    background: #0f172a;
    z-index: 1;
}

/* ── Stats Cards ──────────────────────────────── */
.stat-card {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: -50%; right: -50%;
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.05), transparent 70%);
    transform: rotate(45deg);
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Form Inputs ──────────────────────────────── */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 0.75rem;
    color: #e2e8f0;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    outline: none;
}
.form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(15, 23, 42, 0.8);
}
.form-input::placeholder { color: #475569; }
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

/* ── Buttons ──────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}
.btn-success {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); transform: translateY(-1px); }
.btn-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}
.btn-danger:hover { box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4); transform: translateY(-1px); }
.btn-outline {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}
.btn-outline:hover { background: rgba(148, 163, 184, 0.1); color: #e2e8f0; }

/* ── Toast Notifications ──────────────────────── */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.toast {
    min-width: 320px;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; gap: 0.75rem;
    color: #e2e8f0;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.toast-success { background: rgba(5, 150, 105, 0.85); border-color: rgba(16, 185, 129, 0.3); }
.toast-error { background: rgba(220, 38, 38, 0.85); border-color: rgba(239, 68, 68, 0.3); }
.toast-info { background: rgba(99, 102, 241, 0.85); border-color: rgba(129, 140, 248, 0.3); }
.toast-warning { background: rgba(217, 119, 6, 0.85); border-color: rgba(245, 158, 11, 0.3); }
@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ── Overlay ──────────────────────────────────── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: all 0.3s ease;
}
.overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    transform: scale(0.9); opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.overlay.active .modal { transform: scale(1); opacity: 1; }

/* ── Table ────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.data-table thead th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: rgba(15, 23, 42, 0.4);
}
.data-table thead th:first-child { border-radius: 0.75rem 0 0 0; }
.data-table thead th:last-child { border-radius: 0 0.75rem 0 0; }
.data-table tbody tr {
    transition: all 0.15s ease;
}
.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}
.data-table tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
}

/* ── Badge ────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.25rem;
}

/* ── Loading Spinner ──────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    width: 1.5rem; height: 1.5rem;
    border: 2px solid rgba(148, 163, 184, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Gradient Text ────────────────────────────── */
.gradient-text {
    background: linear-gradient(135deg, #c7d2fe, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.5); }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); position: fixed; z-index: 40; width: 280px !important; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .stat-number { font-size: 1.75rem; }
}

/* ── Pulse glow ───────────────────────────────── */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.6); }
}
.pulse-glow { animation: pulseGlow 2s ease-in-out infinite; }

/* ── Float animation ──────────────────────────── */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}
.float-animation { animation: float 3s ease-in-out infinite; }

/* ── Login page particles ─────────────────────── */
.login-bg {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    overflow: hidden;
}
.login-bg::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    top: 20%; left: 10%;
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
}
.login-bg::after {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 70%);
    bottom: 20%; right: 10%;
    border-radius: 50%;
    animation: float 8s ease-in-out infinite reverse;
}

/* ── File upload area ─────────────────────────── */
.upload-area {
    border: 2px dashed rgba(148, 163, 184, 0.2);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}
.upload-area:hover, .upload-area.dragover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
}

/* ── Document Paper Preview ───────────────────── */
.paper-container {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}
.paper {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    color: #1a1a1a;
    padding: 20mm 25mm 25mm 30mm;
    position: relative;
    box-shadow: 0 4px 40px rgba(0,0,0,0.4);
    font-family: 'Sarabun', 'TH SarabunPSK', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    overflow: hidden;
}

/* ── Stamp Common: สีน้ำเงิน กรอบสี่เหลี่ยม ──── */
/* ตราประทับทั้ง 3 รูปแบบ: น้ำเงิน (#1a47b8) กรอบสี่เหลี่ยม */

/* ── Stamp 1: ตรารับหนังสือ (Receipt - มุมบนขวา) ── */
.stamp-receipt-box {
    position: absolute;
    top: 18mm;
    right: 20mm;
    width: 52mm;
    border: 3px solid #1a47b8;
    border-radius: 3px;
    padding: 6px 10px;
    text-align: center;
    color: #1a47b8;
    font-weight: 700;
    transform: rotate(-1.5deg);
    background: rgba(255,255,255,0.85);
    z-index: 5;
    font-size: 12px;
    box-shadow: 0 0 0 1.5px #fff, 0 0 0 3px rgba(26,71,184,0.08);
}
.stamp-receipt-box::before {
    content: '';
    position: absolute; inset: 2px;
    border: 1.5px solid rgba(26,71,184,0.35);
    border-radius: 2px;
    pointer-events: none;
}
.stamp-receipt-box .stamp-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    border-bottom: 1.5px solid rgba(26,71,184,0.3);
    padding-bottom: 3px;
    margin-bottom: 4px;
}
.stamp-receipt-box .stamp-school {
    font-size: 11.5px;
    font-weight: 800;
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1.5px solid rgba(26,71,184,0.3);
}
.stamp-receipt-box .stamp-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    line-height: 1.5;
}
.stamp-receipt-box .stamp-row .label {
    font-weight: 600;
    opacity: 0.7;
}
.stamp-receipt-box .stamp-row .value {
    font-weight: 800;
}
.stamp-receipt-box::after {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: multiply;
    border-radius: 2px;
}

/* ── Stamp 2: เสนอเพื่อพิจารณา (Proposal - ล่างซ้าย) ── */
.stamp-proposal-box {
    position: absolute;
    bottom: 85mm;
    left: 25mm;
    width: 75mm;
    border: none;
    border-radius: 3px;
    padding: 10px 12px;
    color: #1a47b8;
    font-size: 11.5px;
    transform: rotate(0.5deg);
    background: rgba(255,255,255,0.9);
    z-index: 5;
    line-height: 1.55;
}
.stamp-proposal-box .stamp-title {
    font-size: 12.5px;
    font-weight: 800;
    text-align: center;
    border-bottom: 1.5px solid rgba(26,71,184,0.25);
    padding-bottom: 4px;
    margin-bottom: 6px;
    letter-spacing: 1px;
}
.stamp-proposal-box .stamp-to {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 11.5px;
}
.stamp-proposal-box .stamp-section {
    margin-bottom: 3px;
    font-size: 10.5px;
    line-height: 1.4;
    word-break: break-word;
}
.stamp-proposal-box .stamp-section .sec-label {
    font-weight: 700;
    font-size: 10px;
    opacity: 0.7;
}
.stamp-proposal-box .stamp-sign {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(26,71,184,0.2);
    font-size: 10.5px;
    text-align: center;
}
.stamp-proposal-box .stamp-sign .sign-name {
    font-weight: 700;
}
.stamp-proposal-box::after {
    content: '';
    position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: multiply;
}

.stamp-resolution-box {
    position: absolute;
    bottom: 85mm;
    right: 20mm;
    width: 70mm;
    border: none;
    border-radius: 3px;
    padding: 10px 12px;
    text-align: center;
    color: #1a47b8;
    font-weight: 700;
    transform: rotate(-2deg);
    background: rgba(255,255,255,0.88);
    z-index: 5;
}
.stamp-resolution-box .res-body {
    text-align: left;
    font-size: 11.5px;
    line-height: 1.5;
    margin-bottom: 12px;
}
.stamp-resolution-box .res-sign {
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
}
.stamp-resolution-box .res-sign .sign-name {
    margin-bottom: 2px;
}
.stamp-resolution-box::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 2px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: multiply;
}

/* ── Paper document text ─────────────────────── */
.paper-header { text-align: center; margin-bottom: 18px; }
.paper-header .garuda { width: 60px; margin: 0 auto 4px; opacity: 0.85; }
.paper-header .agency { font-size: 14px; font-weight: 600; }
.paper-header .address { font-size: 13px; color: #444; }
.paper-meta { font-size: 14px; margin-bottom: 10px; }
.paper-body { font-size: 15px; text-indent: 2.5em; margin-bottom: 8px; }
.paper-sign { text-align: center; margin-top: 30px; font-size: 14px; }

/* ── Print styles ─────────────────────────────── */
@media print {
    .sidebar, nav, .no-print, #toast-notification { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .main-content > div { padding: 0 !important; margin: 0 !important; }
    body { background: white !important; color: black !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .paper-container { padding: 0 !important; justify-content: flex-start; }
    .paper { box-shadow: none !important; margin: 0; width: 100%; min-height: auto; }
    .stamp-receipt-box, .stamp-proposal-box, .stamp-resolution-box {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
}

