/**
 * ระบบห้องสมุดเทศบาลเมืองเขลางค์นคร
 * Custom Styles
 */

:root {
    --primary-color: #1a56db;
    --primary-dark: #1e429f;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --light-color: #f3f4f6;
    --dark-color: #111827;
    --gradient-primary: linear-gradient(135deg, #1a56db 0%, #3b82f6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: #f8fafc;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Navbar Styles
   ============================================ */
.navbar {
    background: var(--gradient-primary) !important;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    font-size: 1.1rem;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.75rem 1rem !important;
    border-radius: 8px;
    transition: var(--transition);
    position: relative;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: var(--transition);
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after,
.navbar-nav .nav-link.active::after {
    width: 60%;
}

.user-menu {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem !important;
}

.user-menu img {
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: var(--transition);
}

.user-menu:hover img {
    border-color: #fff;
    transform: scale(1.1);
}

/* ============================================
   Dropdown Animation
   ============================================ */
.dropdown-menu-animated {
    animation: dropdownSlide 0.3s ease;
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--border-radius);
    padding: 0.5rem;
}

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

.dropdown-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
}

.dropdown-item:hover {
    background: var(--light-color);
    transform: translateX(5px);
}

.dropdown-header {
    padding: 1rem;
    background: var(--light-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

/* ============================================
   Card Styles
   ============================================ */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    background: #fff;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e5e7eb;
    padding: 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Stat Cards */
.stat-card {
    position: relative;
    overflow: hidden;
    color: #fff;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.stat-card.primary {
    background: var(--gradient-primary);
}

.stat-card.success {
    background: var(--gradient-success);
}

.stat-card.warning {
    background: var(--gradient-warning);
}

.stat-card.danger {
    background: var(--gradient-danger);
}

.stat-card .stat-icon {
    font-size: 3rem;
    opacity: 0.3;
    position: absolute;
    right: 1rem;
    bottom: 1rem;
}

.stat-card .stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-card .stat-label {
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 500;
}

.stat-card .stat-link {
    color: #fff;
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    margin-top: 1rem;
    opacity: 0.8;
    transition: var(--transition);
}

.stat-card .stat-link:hover {
    opacity: 1;
}

.stat-card .stat-link i {
    margin-left: 0.25rem;
    transition: var(--transition);
}

.stat-card .stat-link:hover i {
    transform: translateX(5px);
}

/* ============================================
   Button Styles
   ============================================ */
.btn {
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    box-shadow: 0 4px 6px -1px rgba(26, 86, 219, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px -1px rgba(26, 86, 219, 0.4);
}

.btn-success {
    background: var(--gradient-success);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-warning {
    background: var(--gradient-warning);
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.3);
    color: #fff;
}

.btn-danger {
    background: var(--gradient-danger);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.1rem;
}

.btn-rounded {
    border-radius: 50px;
}

.btn-floating {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

/* ============================================
   Form Styles
   ============================================ */
.form-control, .form-select {
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(26, 86, 219, 0.1);
}

.form-floating > .form-control,
.form-floating > .form-select {
    border-radius: 10px;
}

.form-label {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.input-group-text {
    border-radius: 10px 0 0 10px;
    border: 2px solid #e5e7eb;
    border-right: none;
    background: #f9fafb;
}

.input-group .form-control {
    border-radius: 0 10px 10px 0;
}

/* ============================================
   Table Styles
   ============================================ */
.table-container {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f9fafb;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: #f9fafb;
}

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

/* ============================================
   Badge Styles
   ============================================ */
.badge {
    padding: 0.5em 0.75em;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-level {
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
}

/* ============================================
   Login Page Styles
   ============================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a56db 0%, #3b82f6 50%, #60a5fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    animation: slideBackground 20s linear infinite;
}

@keyframes slideBackground {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-50%, -50%); }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 3rem;
    width: 100%;
    max-width: 450px;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .logo-icon {
    width: 80px;
    height: 80px;
    background: var(--gradient-primary);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-lg);
}

.login-logo h2 {
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.25rem;
}

.login-logo p {
    color: var(--secondary-color);
}

/* ============================================
   Smart Card Reader Styles
   ============================================ */
.smartcard-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: var(--border-radius);
    padding: 2rem;
    border: 2px dashed #3b82f6;
    text-align: center;
    transition: var(--transition);
}

.smartcard-section:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

.smartcard-section .card-icon {
    width: 100px;
    height: 100px;
    background: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 20px rgba(59, 130, 246, 0);
    }
}

.smartcard-section.reading .card-icon {
    animation: spin 1s linear infinite;
}

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

.id-card-preview {
    background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
}

.id-card-photo {
    width: 120px;
    height: 150px;
    background: #e5e7eb;
    border-radius: 8px;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: var(--shadow);
}

/* ============================================
   Member Card Styles
   ============================================ */
.member-card {
    background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: var(--transition);
    border: 1px solid #e5e7eb;
}

.member-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.member-card .member-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: var(--shadow);
}

/* ============================================
   Loading & Progress Styles
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-bar-animated {
    animation: progressBar 2s ease-in-out infinite;
}

@keyframes progressBar {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ============================================
   Alert & Toast Styles
   ============================================ */
.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.5rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid #e2e8f0;
}

.page-header h1 {
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.page-header .breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
}

/* ============================================
   Modal Styles
   ============================================ */
.modal-content {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    background: var(--gradient-primary);
    color: #fff;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 768px) {
    .stat-card .stat-number {
        font-size: 1.75rem;
    }
    
    .login-card {
        padding: 2rem;
        margin: 1rem;
    }
    
    .navbar-nav .nav-link::after {
        display: none;
    }
}

/* ============================================
   Animation Classes
   ============================================ */
.hover-lift {
    transition: var(--transition);
}

.hover-lift:hover {
    transform: translateY(-5px);
}

.hover-scale {
    transition: var(--transition);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Custom Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
