@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: linear-gradient(135deg, #3798ff 0%, #b1b2b5 100%);
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-10px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(10px);
    }
}

/* === LOGIN PAGE === */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-card {
    background: white;
    width: 100%;
    max-width: 440px;
    padding: 45px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.6s ease-out;
    position: relative;
    z-index: 10;
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.login-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.login-header h2 span {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    line-height: 1.3;
    padding-bottom: 5px;
    padding-right: 2px;
    margin-top: 4px;
}

.login-icon {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.login-header p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-tabs {
    display: flex;
    background: var(--bg-color);
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Sarabun';
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.3s;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.form-group {
    margin-bottom: 24px;
    animation: slideIn 0.5s ease-out backwards;
}

.form-group:nth-child(2) {
    animation-delay: 0.1s;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-family: 'Sarabun';
    font-size: 1rem;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn-login {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Sarabun';
    transition: all 0.3s;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    margin-bottom: 20px;
    text-align: center;
    background: #fee2e2;
    padding: 12px;
    border-radius: 10px;
    border-left: 4px solid var(--danger);
}

/* === LAYOUT & NAVBAR === */
.navbar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.nav-brand h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
}

.sub-brand {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.nav-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    border: 2px solid var(--danger);
    color: var(--danger);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
}

.content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.page-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    height: fit-content;
    transition: transform 0.3s;
}

.card-header h2 {
    font-size: 1.25rem;
    color: var(--text-color);
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* === GLOBAL TABLES & STATUS === */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 14px;
    background: var(--bg-color);
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.pending {
    background: #fef3c7;
    color: #d97706;
}

.status-badge.approved {
    background: #d1fae5;
    color: #059669;
}

.status-badge.active {
    background: #dbeafe;
    color: #2563eb;
}

.status-badge.returned {
    background: #f3f4f6;
    color: #4b5563;
}

.status-badge.cancelled {
    background: #fee2e2;
    color: #dc2626;
}

.btn-reason {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-reason:hover {
    background: var(--danger);
    color: white;
}

/* === COMMON MODALS === */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.custom-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.custom-modal-card {
    background: white;
    width: 90%;
    max-width: 420px;
    padding: 35px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    transform: translateY(30px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
}

.custom-modal-card.active {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
    background: #f1f5f9;
}

.modal-icon-circle.danger {
    background: #fee2e2;
    color: #dc2626;
}

.modal-icon-circle.warning {
    background: #fef3c7;
    color: #d97706;
}

.modal-icon-circle.info {
    background: #dbeafe;
    color: #2563eb;
}

.custom-modal-card h3 {
    margin: 0 0 10px 0;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.modern-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-family: 'Sarabun';
    font-size: 1rem;
    margin-bottom: 25px;
    min-height: 100px;
    transition: border 0.3s;
}

.modern-textarea:focus {
    border-color: var(--warning);
    outline: none;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Sarabun';
    transition: all 0.2s;
}

.btn-modal-cancel {
    background: white;
    border: 2px solid #e2e8f0;
    color: var(--text-muted);
}

.btn-modal-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-modal-confirm.danger {
    background: var(--danger);
    color: white;
    border: none;
}

.btn-modal-confirm.danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-modal-confirm.warning {
    background: var(--warning);
    color: white;
    border: none;
}

.btn-modal-confirm.warning:hover {
    background: #d97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-modal-confirm.primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-modal-confirm.primary:hover {
    background: var(--primary-dark);
}

.full-width {
    width: 100%;
}

.reason-content-box {
    background: #f1f5f9;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: left;
    color: var(--text-color);
    border: 1px dashed #cbd5e1;
}

@media (max-width: 600px) {
    .login-card {
        padding: 30px 20px;
    }

    .navbar {
        padding: 1rem;
    }

    .user-badge {
        display: none;
    }

    .card-header {
        align-items: flex-start;
    }
}