/* Pro-Thai Custom Styles */

/* ===== CSS Variables (Design Tokens) ===== */
:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --accent: #f59e0b;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    /* Darkened from the original cyan→mint (#0cebeb→#29ffc6): white label text on that
       scored ~1.3:1 contrast, far below the 4.5:1 floor. Emerald keeps the "success" identity
       while making the label readable (~3.8:1 at the lightest stop). */
    --gradient-success: linear-gradient(135deg, #065f46 0%, #047857 55%, #059669 100%);
    --gradient-sunset: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --gradient-ocean: linear-gradient(135deg, #667eea 0%, #4f46e5 50%, #6366f1 100%);

    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Global Resets & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(to bottom, var(--gray-50), var(--gray-100));
    min-height: 100vh;
}

/* ===== Premium Card Styles ===== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

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

.card:hover::before {
    opacity: 1;
}

/* Glass Card Effect */
.card-glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-lg);
}

/* ===== Button Styles ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

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

.btn-success {
    background: var(--gradient-success);
    color: white;
}

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

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
    /* dim warning color */
}

/* Neutral button — used for Back / Cancel. Was referenced by markup but never defined, so
   those buttons inherited bare .btn (no background, no colour) and rendered invisible. */
.btn-secondary {
    background: #4b5563;
    color: white;
}

.btn-secondary:hover {
    background: #374151;
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.875rem;
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: 1.125rem;
}

/* Loading State */
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== Badge Styles ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* Neutral badge — used for EXPIRED rentals, MEMBER role, unclassified security events.
   Was referenced by markup but never defined, so those badges rendered as bare text. */
.badge-secondary {
    background: rgba(107, 114, 128, 0.14);
    color: #4b5563;
}

.dark .badge-secondary {
    color: #d1d5db;
}

/* ===== Alert Styles ===== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
}

.alert::before {
    content: '';
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: var(--success);
}

.alert-success::before {
    content: '✓';
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: var(--danger);
}

/* .alert-error is the alias used by manage_security / manage_announcements; without this it
   inherited the empty .alert::before box and rendered a blank 20px gap where the icon goes. */
.alert-danger::before,
.alert-error::before {
    content: '✕';
    background: var(--danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: var(--warning);
}

.alert-warning::before {
    content: '⚠';
    background: var(--warning);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

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

.alert-info::before {
    content: 'ℹ';
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

/* ===== Product Card Styles ===== */
.product-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    height: 100%;
    display: flex;
    flex-direction: column;
}

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

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.product-card:hover .product-image {
    transform: scale(1.1);
}

.product-image-container {
    overflow: hidden;
    position: relative;
}

.product-image-placeholder {
    width: 100%;
    height: 200px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}

/* ===== Stats Card ===== */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover::before {
    opacity: 0.05;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Table Styles ===== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.table {
    width: 100%;
    background: white;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

.table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--gray-200);
}

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

.table tbody tr:hover {
    background: var(--gray-50);
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--gray-700);
}

.form-input {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-base);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--gray-300);
}

/* ===== Alert Styles ===== */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: white;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-100);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    color: #3730a3;
    border-left: 4px solid var(--primary);
}

/* Dark mode: the alert bodies use translucent tints (fine on either theme) but their text colours
   are dark-on-light only. Without these the "how to use" / status banners sit near-invisible on a
   dark card — most visibly the .alert-info box on my_rentals. */
.dark .alert-success {
    color: #86efac;
}

.dark .alert-danger,
.dark .alert-error {
    color: #fca5a5;
}

.dark .alert-warning {
    color: #fcd34d;
}

.dark .alert-info {
    color: #a5b4fc;
}

/* ===== Hero Section ===== */
.hero {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-2xl) 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="2" fill="rgba(255,255,255,0.1)"/></svg>');
    opacity: 0.3;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    position: relative;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: var(--space-xl);
    position: relative;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp var(--transition-base) ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideIn var(--transition-base) ease-out;
}

/* Pulse animation for notifications */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.animate-\[shimmer_1\.5s_infinite\] {
    animation: shimmer 1.5s infinite;
}

/* ===== Countdown Timer ===== */
.countdown {
    display: inline-flex;
    gap: var(--space-sm);
    font-weight: 600;
    color: var(--primary);
}

.countdown-urgent {
    color: var(--danger);
    animation: pulse 1s infinite;
}

/* ===== Utility Classes ===== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .table-container {
        font-size: 0.875rem;
    }
}

/* ===== Loading Spinner ===== */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ===== Dark Mode Overrides ===== */
.dark body {
    background: var(--gray-900);
    color: var(--gray-100);
}

.dark .card,
.dark .stat-card,
.dark .product-card,
.dark .table,
.dark .bg-white {
    background: var(--gray-800) !important;
    color: var(--gray-100);
    border-color: var(--gray-700);
}

.dark .text-gray-800 {
    color: var(--gray-100) !important;
}

.dark .text-gray-700 {
    color: var(--gray-300) !important;
}

.dark .text-gray-600 {
    color: var(--gray-400) !important;
}

.dark .text-gray-500 {
    color: var(--gray-500) !important;
}

.dark .bg-gray-50,
.dark .hover\:bg-gray-50:hover {
    background-color: #111827 !important;
    /* gray-900 */
}

.dark .border-gray-200,
.dark .border-gray-100 {
    border-color: var(--gray-700) !important;
}

.dark .form-input {
    background-color: var(--gray-900);
    border-color: var(--gray-700);
    color: white;
}

.dark .table thead {
    background-color: var(--gray-900);
}

.dark .table th {
    color: var(--gray-300);
    border-bottom-color: var(--gray-700);
}

.dark .table td {
    border-bottom-color: var(--gray-700);
}

.dark .table tbody tr:hover,
.dark .table tbody tr:hover td {
    background-color: #1f2937 !important;
    /* gray-800 */
    color: white !important;
}

/* SweetAlert2 Dark Mode Overrides */
.dark .swal2-popup {
    background: var(--gray-800) !important;
    color: var(--gray-100) !important;
}

.dark .swal2-title,
.dark .swal2-content,
.dark .swal2-html-container {
    color: var(--gray-100) !important;
}

.dark .swal2-input,
.dark .swal2-file,
.dark .swal2-textarea,
.dark .swal2-select {
    background: var(--gray-900) !important;
    color: white !important;
    border-color: var(--gray-700) !important;
    box-shadow: none !important;
}

.dark .swal2-label {
    color: var(--gray-100) !important;
}

/* ===== Scroll to Top/Bottom Buttons ===== */
.scroll-btn-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9000;
}

.scroll-btn {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-xl);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 1.25rem;
    opacity: 0.9;
    backdrop-filter: blur(5px);
}

.scroll-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.5);
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.5);
}

.scroll-btn i {
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

.dark .scroll-btn {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

.dark .scroll-btn:hover {
    box-shadow: 0 10px 30px -5px rgba(99, 102, 241, 0.6);
}

/* --- Reusable cell tooltip + click-to-expand (admin log tables) ---------------
   Opt-in: add class "tipcell" + data-tip="<full text>" to a truncated cell.
   Hover (only when the text is actually cut) → styled bubble; click → full modal.
   Dark bubble reads well in both themes, so no theme variant needed. */
.tipcell { cursor: pointer; }
#celltip {
    position: fixed;
    z-index: 9999;
    max-width: 380px;
    padding: 8px 11px;
    border-radius: 8px;
    background: #111827;
    color: #f9fafb;
    font-size: 12.5px;
    line-height: 1.55;
    box-shadow: 0 10px 30px -4px rgba(0, 0, 0, .45);
    white-space: pre-wrap;
    word-break: break-word;
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s ease;
}
#celltip.show { opacity: 1; }
.celltip-text { text-align: left !important; white-space: pre-wrap; word-break: break-word; }