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

:root {
    --bg-primary: #1a1d23;
    --bg-secondary: #25282e;
    --bg-tertiary: #2d3139;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --border-color: #3a3d45;
    --accent-blue: #4a9eff;
    --accent-blue-hover: #3d8fe8;
    --accent-green: #4ade80;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Board Layout with Sidebar */
.board-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

.board-main-content {
    min-width: 0;
}

.board-sidebar {
    position: relative;
}

@media (max-width: 1200px) {
    .board-layout {
        grid-template-columns: 1fr;
    }
    
    .board-sidebar {
        order: -1;
    }
    
    .board-sidebar .info-card {
        position: static !important;
    }
    
    .square-cell {
        height: 55px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .square-cell {
        height: 45px;
        padding: 2px;
    }
    
    .number-cell {
        font-size: 11px;
        padding: 4px;
    }
    
    .team-header {
        font-size: 13px;
        padding: 8px;
    }
    
    .vertical-text {
        font-size: 12px;
    }
    
    .square-owner {
        font-size: 8px;
    }
    
    .squares-board {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .square-cell {
        height: 35px;
        padding: 2px;
    }
    
    .number-cell {
        font-size: 10px;
        padding: 2px;
    }
    
    .team-header {
        font-size: 11px;
        padding: 6px;
    }
    
    .vertical-text {
        font-size: 11px;
    }
    
    .square-owner {
        font-size: 7px;
    }
    
    .squares-board {
        padding: 8px;
    }
}

/* Page Headings */
h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
}

h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

p {
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Page Title Section */
.page-title {
    margin: 32px 0;
}

.page-title h1 {
    margin-bottom: 8px;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Cart Counter Badge */
.cart-badge {
    background: var(--accent-blue);
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 4px;
    display: inline-block;
}

/* Navigation */
.navbar {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0;
    box-shadow: 0 2px 8px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

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

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.5px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.logo:hover {
    color: var(--accent-blue-hover);
}

.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
}

.nav-links a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-links a.active {
    background: var(--bg-tertiary);
    color: var(--accent-blue);
    font-weight: 600;
}

.nav-links a.admin-link {
    color: var(--accent-yellow);
}

.nav-links a.admin-link:hover {
    background: var(--bg-tertiary);
    color: var(--accent-yellow);
}

.nav-links .user-welcome {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 0 8px;
    border-left: 1px solid var(--border-color);
    margin-left: 8px;
}

.nav-links span {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 0 8px;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.dropdown-toggle:hover {
    background: var(--border-color);
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    padding-top: 4px;
    margin-top: -4px;
}

.dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px var(--shadow);
}

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

.btn-primary:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(74, 158, 255, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

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

.btn-danger:hover {
    background: #ef4444;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(248, 113, 113, 0.3);
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

/* Auth Pages */
.auth-box {
    max-width: 440px;
    margin: 60px auto;
    background: var(--bg-secondary);
    padding: 48px;
    border-radius: 16px;
    box-shadow: 0 4px 24px var(--shadow);
    border: 1px solid var(--border-color);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 32px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 28px;
}

.auth-link {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
}

.auth-link a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
    color: var(--accent-blue-hover);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.alert-success {
    background: rgba(74, 222, 128, 0.1);
    color: var(--accent-green);
    border-left-color: var(--accent-green);
}

.alert-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--accent-red);
    border-left-color: var(--accent-red);
}

.alert-info {
    background: rgba(74, 158, 255, 0.1);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

/* Boards Grid */
.boards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

.board-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.board-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--accent-blue);
}

.board-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 20px;
}

.board-info p {
    margin: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.board-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

.board-info .payouts {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

.board-info .payouts p {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.board-info .payouts ul {
    list-style: none;
    padding-left: 0;
}

.board-info .payouts li {
    padding: 4px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Board View */
.board-header {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
}

.board-header h1 {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 16px;
}

.board-header p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.board-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.info-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
}

.board-info-compact {
    padding: 16px 20px;
}

.info-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 32px;
}

.info-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
}

.info-card ul {
    list-style: none;
}

.info-card li {
    padding: 5px 0;
}

/* Squares Board */
.squares-board {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow-x: auto;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    width: 100%;
}

.squares-board::-webkit-scrollbar {
    height: 8px;
}

.squares-board::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.squares-board::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.squares-board::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.squares-table {
    border-collapse: collapse;
    width: 100%;
}

.squares-table th,
.squares-table td {
    border: 2px solid #555;
    text-align: center;
}

.corner-cell {
    background: #f5f5f5;
    width: 40px;
    height: 40px;
}

.corner-cell {
    background: var(--bg-tertiary);
    width: 35px;
    height: 35px;
    font-size: 10px;
}

.number-cell {
    background: rgba(74, 158, 255, 0.2);
    color: var(--accent-blue);
    font-weight: 700;
    padding: 6px;
    min-width: 35px;
    font-size: 14px;
}

.team-header {
    background: var(--accent-blue);
    color: white;
    padding: 10px;
    font-size: 15px;
    font-weight: 600;
}

.team-vertical {
    background: var(--accent-blue);
    color: white;
    padding: 10px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    min-width: 35px;
}

.vertical-text {
    transform: rotate(180deg);
    font-size: 15px;
    font-weight: 600;
}

.square-cell {
    width: 8%;
    height: 65px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 2px solid #555;
}

.square-available {
    background: var(--bg-tertiary);
}

.square-available:hover {
    background: rgba(74, 158, 255, 0.15);
    transform: scale(1.05);
    border-color: var(--accent-blue);
}

.square-taken {
    background: rgba(156, 163, 175, 0.35);
    color: #d1d5db;
    border-color: rgba(156, 163, 175, 0.5);
}

.square-mine {
    background: rgba(34, 197, 94, 0.35);
    font-weight: 700;
    color: #4ade80;
    border-color: #22c55e;
}

.square-in-cart {
    background: rgba(251, 191, 36, 0.35);
    font-weight: 600;
    color: #fbbf24;
    border-color: #f59e0b;
}

.square-charity {
    background: rgba(249, 115, 22, 0.35);
    font-weight: 600;
    color: #fb923c;
    border-color: #f97316;
    cursor: not-allowed;
}

.square-winner {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%) !important;
    font-weight: 700;
    color: #000 !important;
    border: 3px solid #ffa500 !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3) !important;
    animation: pulse-winner 2s ease-in-out infinite;
    position: relative;
    z-index: 10;
}

@keyframes pulse-winner {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.5);
    }
}

.square-owner {
    font-size: 9px;
    word-break: break-word;
    display: block;
    line-height: 1.2;
}

/* Legend */
.legend {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    gap: 24px;
    align-items: center;
    border: 1px solid var(--border-color);
}

.legend h3 {
    margin: 0;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-box {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    display: inline-block;
    border-radius: 6px;
}

/* Apply the square colors to legend boxes */
.legend-box.square-available {
    background: rgba(74, 158, 255, 0.25);
    border-color: var(--accent-blue);
}

.legend-box.square-taken {
    background: rgba(156, 163, 175, 0.35);
    border-color: rgba(156, 163, 175, 0.5);
}

.legend-box.square-mine {
    background: rgba(34, 197, 94, 0.35);
    border-color: #22c55e;
}

.legend-box.square-charity {
    background: rgba(249, 115, 22, 0.35);
    border-color: #f97316;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 8px 32px var(--shadow);
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-weight: 700;
}

/* Admin Styles */
.admin-section {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
}

.admin-section h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
    font-weight: 700;
    font-size: 24px;
}

.admin-form {
    max-width: 800px;
}

.admin-table {
    overflow-x: auto;
}

.admin-table table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: var(--bg-tertiary);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    color: var(--text-secondary);
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
    border-color: var(--accent-blue);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-blue);
    margin: 12px 0;
}

.stat-note {
    font-size: 12px;
    color: #999;
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-green);
}

.status-locked {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-yellow);
}

.status-completed {
    background: rgba(74, 158, 255, 0.2);
    color: var(--accent-blue);
}

/* Transaction Types */
.transaction-type {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transaction-deposit {
    background: rgba(74, 222, 128, 0.2);
    color: var(--accent-green);
}

.transaction-purchase {
    background: rgba(248, 113, 113, 0.2);
    color: var(--accent-red);
}

.transaction-winning {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-yellow);
}

.transaction-refund {
    background: rgba(74, 158, 255, 0.2);
    color: var(--accent-blue);
}

/* Dashboard */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.dashboard-section {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
}

.dashboard-section h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
    font-weight: 700;
    font-size: 24px;
}

.dashboard-table {
    overflow-x: auto;
}

.dashboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.dashboard-table th,
.dashboard-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.dashboard-table th {
    background: var(--bg-tertiary);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-table td {
    color: var(--text-secondary);
}

.amount-positive {
    color: var(--accent-green);
    font-weight: 700;
}

.amount-negative {
    color: var(--accent-red);
    font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .nav-links a {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .dropdown-menu {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .squares-table {
        font-size: 11px;
    }
    
    .square-cell {
        width: 45px;
        height: 45px;
        padding: 3px;
    }
    
    .square-owner {
        font-size: 7px;
    }
    
    .number-cell {
        font-size: 11px;
        padding: 4px;
    }
    
    .team-header {
        font-size: 12px;
        padding: 8px;
    }
    
    .auth-box {
        padding: 32px 24px;
        margin: 40px 20px;
    }
    
    .container {
        padding: 16px;
    }
    
    .board-header,
    .admin-section,
    .dashboard-section {
        padding: 24px 16px;
    }
}
