/* =============================================================================
   BASE STYLES AND VARIABLES
   ============================================================================= */

/* Reset styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Color variables and theme configuration */
:root {
    /* Primary colors */
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #1e293b;
    
    /* Background colors */
    --background-color: #f1f5f9;
    --card-background: #ffffff;
    --header-bg: #1e293b;
    --tile-hover: #f8fafc;
    
    /* Text colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --header-text: #f8fafc;
    
    /* Status colors */
    --success-color: #16a34a;
    --success-hover: #15803d;
    --error-color: #dc2626;
    --error-hover: #b91c1c;
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    
    /* Utility colors */
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Base body styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    background-color: var(--background-color);
    color: var(--text-primary);
}

/* =============================================================================
   LAYOUT COMPONENTS
   ============================================================================= */

/* Main container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
    margin-bottom: 1.5rem;
}

/* Header styles */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    
    & .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        max-width: 1280px;
        margin: 0 auto;
        padding: 0 1rem;
    }
    
    & h1 {
        font-size: 1.75rem;
        font-weight: 600;
        letter-spacing: -0.025em;
    }
}

/* Admin stats in header */
.admin-stats {
    display: flex;
    align-items: center;
    margin-left: auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    
    & .stat-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.5rem 0.75rem;
        border-radius: 6px;
        transition: all 0.2s ease-in-out;
        min-width: 140px;
        
        &:hover {
            background: rgba(255, 255, 255, 0.1);
        }
    }
    
    & .stat-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        font-size: 1rem;
    }
    
    & .stat-info {
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
    }
    
    & .stat-label {
        font-size: 0.75rem;
        color: rgba(255, 255, 255, 0.7);
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }
    
    & .stat-value {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--header-text);
    }
    
    & .stat-divider {
        width: 1px;
        height: 24px;
        background: rgba(255, 255, 255, 0.1);
        margin: 0 0.25rem;
    }
}

/* Grid layout for sections */
.sections-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.action-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* =============================================================================
   ADMIN SECTION COMPONENTS
   ============================================================================= */

/* Admin section cards */
.admin-section {
    background-color: var(--card-background);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border: none;
    transition: all 0.3s ease-in-out;
    height: auto;
    max-height: calc(100vw / 3);
    
    &:hover {
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        transform: translateY(-4px);
    }
    
    &:active {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    
    &.square-ratio {
        aspect-ratio: 1 / 1;
    }
}

/* Player list section */
.player-list-section {
    grid-column: span 1;
    height: auto;
    max-height: calc(100vw / 3);
}

.player-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding-right: 0.5rem;
    margin-right: -0.5rem;
    
    /* Customize scrollbar for webkit browsers */
    &::-webkit-scrollbar {
        width: 6px;
    }
    
    &::-webkit-scrollbar-track {
        background: transparent;
        margin: 0.5rem;
    }
    
    &::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.1);
        border-radius: 3px;
        
        &:hover {
            background-color: rgba(0, 0, 0, 0.2);
        }
    }
}

/* Player item in the list */
.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--card-background);
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 0.5rem;
    
    &:last-child {
        margin-bottom: 0;
    }
    
    &:hover {
        background-color: var(--tile-hover);
        box-shadow: 0 4px 6px var(--shadow-color);
        transform: translateY(-2px);
    }
    
    & .player-info {
        display: flex;
        align-items: center;
        gap: 1rem;
        flex: 1;
    }
    
    & .player-name {
        font-weight: 600;
        color: var(--text-primary);
    }
    
    & .player-money {
        font-size: 0.875rem;
        color: var(--success-color);
        font-weight: 500;
    }
    
    & .player-actions {
        display: flex;
        gap: 0.5rem;
    }
}

/* Player role badges */
.player-role {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.role-admin {
    background-color: var(--error-color);
    color: white;
}

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

.role-player {
    background-color: var(--success-color);
    color: white;
}

/* =============================================================================
   BUTTONS AND INTERACTIVE ELEMENTS
   ============================================================================= */

/* Action buttons */
.action-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.promote-btn {
    background-color: #22c55e;
    color: white;
    
    &:hover {
        background-color: #16a34a;
    }
}

.demote-btn {
    background-color: #ef4444;
    color: white;
    
    &:hover {
        background-color: #dc2626;
    }
}

.message-btn {
    background-color: #3b82f6;
    color: white;
    
    &:hover {
        background-color: #2563eb;
    }
}

/* Search and filter components */
.search-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-primary);
    background-color: var(--card-background);
    transition: all 0.2s ease-in-out;
    
    &:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    &:hover {
        border-color: var(--primary-color);
    }
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    background-color: var(--card-background);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease-in-out;
    
    &:hover {
        border-color: var(--primary-color);
        color: var(--primary-color);
    }
    
    &.active {
        background-color: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }
}

/* =============================================================================
   FORMS AND INPUTS
   ============================================================================= */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    
    & label {
        font-weight: 500;
        color: var(--text-secondary);
        font-size: 0.875rem;
    }
    
    & input {
        padding: 0.75rem 1rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        font-size: 1rem;
        color: var(--text-primary);
        background-color: var(--card-background);
        transition: all 0.2s ease-in-out;
        
        &:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }
        
        &:hover {
            border-color: var(--primary-color);
        }
    }
}

.submit-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s ease-in-out;
    opacity: 0.9;
    margin-top: auto;
    
    &:hover {
        background-color: var(--primary-hover);
        opacity: 1;
        transform: translateY(-2px);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* =============================================================================
   MODALS
   ============================================================================= */

   .modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 12px;
    min-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    
    & h2 {
        font-size: 1.25rem;
        color: var(--text-primary);
        font-weight: 600;
    }
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease-in-out;
    
    &:hover {
        color: var(--text-primary);
    }
}

/* =============================================================================
   BADGES AND STATUS INDICATORS
   ============================================================================= */

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Rank & Side badges */
.player-rank,
.player-side {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Rank styling based on type */
.rank-enlisted {
    background-color: #e2e8f0;
    color: #475569;
}

.rank-warrant {
    background-color: #bfdbfe;
    color: #1e40af;
}

.rank-officer {
    background-color: #3b82f6;
    color: #ffffff;
}

/* Side indicators */
.side-west {
    background-color: #3b82f6;
    color: white;
}

.side-east {
    background-color: #ef4444;
    color: white;
}

.side-guer {
    background-color: #22c55e;
    color: white;
}

.side-civ {
    background-color: #a855f7;
    color: white;
}

/* Player payday indicator */
.player-payday {
    font-size: 0.75rem;
    color: var(--success-color);
    font-weight: 500;
    background-color: rgba(22, 163, 74, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

/* Description text */
.payday-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

/* Adjustments for smaller screens */
@media (max-width: 768px) {
    .action-sections {
        grid-template-columns: 1fr;
    }
    
    .player-item {
        flex-direction: column;
        align-items: flex-start;
        
        & .player-info {
            margin-bottom: 1rem;
            flex-wrap: wrap;
        }
        
        & .player-actions {
            width: 100%;
            justify-content: space-between;
        }
    }
    
    .filter-bar {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .modal-content {
        min-width: 90%;
        max-width: 90%;
    }
}

/* Adjustments for very small screens */
@media (max-width: 480px) {
    .admin-stats {
        flex-direction: column;
        
        & .stat-divider {
            width: 80%;
            height: 1px;
            margin: 0.25rem 0;
        }
    }
    
    .action-btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}