/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #DC143C;
    --dark-red: #8B0000;
    --black: #000000;
    --dark-gray: #1a1a1a;
    --gray: #333333;
    --light-gray: #666666;
    --lighter-gray: #999999;
    --white: #ffffff;
    --bg-dark: #0d0d0d;
    --bg-gray: #1f1f1f;
}

body {
    font-family: 'Sarabun', 'Kanit', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-gray) 100%);
    color: var(--white);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    background: var(--black);
    padding: 0.6rem 0;
    box-shadow: 0 2px 10px rgba(220, 20, 60, 0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    text-decoration: none;
    font-size: 1rem;
    font-weight: bold;
}

.nav-brand .logo {
    height: 40px;
    width: auto;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-menu a {
    color: var(--white);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 5px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    position: relative;
    z-index: 1; /* Ensure links are above other elements */
    cursor: pointer;
}

.nav-menu a:hover {
    background: var(--primary-red);
    color: var(--white);
}

.nav-menu a.active {
    background: var(--primary-red);
    color: var(--white);
    border-bottom: 2px solid var(--white);
}

.dropdown {
    position: relative;
    z-index: 1000; /* Keep dropdown above other nav items */
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: var(--dark-gray);
    list-style: none;
    min-width: 200px;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: none;
    padding: 10px 0;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    border: 1px solid var(--gray);
}

.dropdown:hover .dropdown-menu {
    display: block;
    opacity: 1;
    visibility: visible;
}

/* Create invisible bridge between trigger and menu */
.dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 5px;
    background: transparent;
    z-index: 1002;
    pointer-events: none; /* Don't block clicks on other elements */
}

.dropdown-menu li {
    padding: 0;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    border-radius: 0;
    transition: background 0.2s ease;
    font-size: 0.85rem;
}

.dropdown-menu a:hover {
    background: var(--primary-red);
    color: var(--white);
}

/* Ensure dropdown menu stays visible when hovering over it */
.dropdown-menu:hover {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 5px;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: var(--white);
    transition: all 0.3s;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Cards */
.card {
    background: var(--dark-gray);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid var(--gray);
}

.card-header {
    border-bottom: 2px solid var(--primary-red);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-header h2 {
    color: var(--primary-red);
    font-size: 1.5rem;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--dark-red);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 20, 60, 0.4);
}

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

.btn-secondary:hover {
    background: var(--light-gray);
}

.btn-success {
    background: #28a745;
    color: var(--white);
}

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

.btn-sm {
    padding: 5px 15px;
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--white);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--gray);
    border-radius: 5px;
    background: var(--bg-gray);
    color: var(--white);
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.form-control::placeholder {
    color: var(--lighter-gray);
}

/* Lottery Grid */
.lottery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.lottery-card {
    background: var(--dark-gray);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.lottery-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-red);
    transform: scaleX(0);
    transition: transform 0.3s;
}

.lottery-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-red);
    box-shadow: 0 10px 30px rgba(220, 20, 60, 0.3);
}

.lottery-card:hover::before {
    transform: scaleX(1);
}

.lottery-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 15px;
}

.lottery-card h3 {
    color: var(--primary-red);
    margin-bottom: 10px;
}

/* Round List */
.round-list {
    list-style: none;
}

.round-item {
    background: var(--bg-gray);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    border-left: 4px solid var(--primary-red);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.round-item.open {
    border-left-color: #28a745;
}

.round-item.closed {
    border-left-color: var(--light-gray);
    opacity: 0.7;
}

.countdown {
    font-size: 1.2rem;
    color: var(--primary-red);
    font-weight: bold;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray);
}

.table th {
    background: var(--black);
    color: var(--primary-red);
    font-weight: bold;
}

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

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid #28a745;
    color: #28a745;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid #dc3545;
    color: #dc3545;
}

.alert-info {
    background: rgba(23, 162, 184, 0.2);
    border: 1px solid #17a2b8;
    color: #17a2b8;
}

/* Footer */
.footer {
    background: var(--black);
    padding: 30px 0 15px;
    margin-top: 50px;
    border-top: 2px solid var(--primary-red);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 20px;
}

.footer-section h3 {
    color: var(--primary-red);
    margin-bottom: 15px;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section a {
    color: var(--white);
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: var(--primary-red);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--gray);
    color: var(--lighter-gray);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 60px;
        flex-direction: column;
        background: var(--black);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 27px rgba(0,0,0,0.05);
        padding: 20px 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .lottery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

/* Loading Spinner */
.spinner {
    border: 4px solid var(--gray);
    border-top: 4px solid var(--primary-red);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
}

.badge-success {
    background: #28a745;
    color: var(--white);
}

.badge-danger {
    background: #dc3545;
    color: var(--white);
}

.badge-warning {
    background: #ffc107;
    color: var(--black);
}

/* Money Display */
.money {
    color: #28a745;
    font-weight: bold;
    font-size: 1.2rem;
}

.money.negative {
    color: #dc3545;
}

/* Admin Dashboard Cards */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.admin-card {
    background: var(--bg-gray);
    border-radius: 10px;
    padding: 25px;
    text-decoration: none;
    color: var(--white);
    transition: all 0.3s ease;
    border: 1px solid var(--gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: visible;
    cursor: pointer;
}

.admin-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-red);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

.admin-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-red);
    box-shadow: 0 10px 30px rgba(220, 20, 60, 0.3);
    text-decoration: none;
    color: var(--white);
}

.admin-card:hover::before {
    transform: scaleX(1);
}

.admin-card-icon {
    font-size: 2.5rem;
    color: var(--primary-red);
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.admin-card:hover .admin-card-icon {
    transform: scale(1.1);
    color: var(--primary-red);
}

.admin-card h3 {
    color: var(--primary-red);
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.admin-card:hover h3 {
    color: var(--primary-red);
}

.admin-card p {
    color: var(--lighter-gray);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.admin-card:hover p {
    color: var(--white);
}

