/* Freaks Campaign Manager - Final Refactored CSS */

/* ======================================== */
/* === 1. Reset & Base Styles === */
/* ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    color: #00ff41;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased; /* Smoother fonts on WebKit browsers */
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* ======================================== */
/* === 2. Typography === */
/* ======================================== */

h1, h2, h3 {
    font-weight: normal;
}

h1 {
    font-size: 3rem;
    text-align: center;
    color: #ff0080;
    text-shadow: 0 0 10px #ff0080, 0 0 20px #ff0080;
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 3px;
}

h1 a {
    color: inherit;
    text-decoration: none;
}

h2 {
    font-size: 1.5rem;
    text-align: center;
    color: #00ffff;
    margin-bottom: 20px;
}

h3 {
    color: #ffff00;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.main-footer p {
    text-align: center;
}

.status {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Campaign Status Colors */
.status-recruiting {
    color: #00ff41;
    background: rgba(0, 255, 65, 0.1);
}

.status-active {
    color: #00ffff;
    background: rgba(0, 255, 255, 0.1);
}

.status-on_hold {
    color: #ffff00;
    background: rgba(255, 255, 0, 0.1);
}

.status-completed {
    color: #ff0080;
    background: rgba(255, 0, 128, 0.1);
}

/* ==================================================== */
/* === 3. Common Components (Buttons, Cards, etc.) === */
/* ================================================== */

.btn {
    display: inline-block;
    padding: 12px 30px;
    border: 2px solid;
    background: transparent;
    color: inherit;
    text-decoration: none;
    font: inherit;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    border-radius: 3px;
    -webkit-appearance: none; /* Remove default styling on buttons in Safari */
}

.btn-primary {
    border-color: #ff0080;
    color: #ff0080;
}

.btn-secondary {
    border-color: #00ffff;
    color: #00ffff;
}

.btn:hover, .btn:active {
    color: #000;
    box-shadow: 0 0 15px currentColor;
}

.btn-primary:hover, .btn-primary:active {
    background: #ff0080;
}

.btn-secondary:hover, .btn-secondary:active {
    background: #00ffff;
}

.resource-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 10px 0;
}
.btn-adjust {
    font-family: var(--font-header);
    background: none;
    border: 2px solid var(--color-cyan);
    color: var(--color-cyan);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 12px;
    margin: 0 15px;
}
.btn-adjust:hover {
    background: var(--color-cyan);
    color: var(--color-bg-dark);
}

/* --- Containers & Cards --- */
.campaign-card,
.character-card,
.form-section,
.character-section,
.auth-form,
.stat-block,
.resource-block,
.character-header,
.game-info {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #00ff41;
    padding: 20px;
    border-radius: 5px;
}

.character-header { border-color: #ff0080; }
.resource-block { border-color: rgba(255, 0, 128, 0.5); }
.stat-block { border-color: rgba(0, 255, 65, 0.5); }

#personal-roller-ui {
    flex-wrap: wrap; /* Allows buttons to wrap onto the next line */
}

.campaign-card p {
    text-align: justify;
}

.character-summary a {
    color: #ffff00;
}

/* ======================================== */
/* === 4. Forms & Inputs === */
/* ======================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #00ffff;
    font-weight: bold;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #00ff41;
    background: rgba(0, 0, 0, 0.5);
    color: #00ff41;
    font: inherit; /* Inherit font from body */
    font-size: 1rem;
    border-radius: 3px;
    -webkit-appearance: none; /* Critical for Safari custom styling */
    appearance: none;
}

.form-group select {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2300FF41%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: .65em auto;
    padding-right: 2.5rem; /* Make room for arrow */
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #ff0080;
    box-shadow: 0 0 5px #ff0080;
}

.add-ability {
    /* This ensures the container itself can be constrained */
    min-width: 0;
}

.add-ability select {
    /* This is the core fix */
    width: 100%; /* Make the select element fill its container */
    overflow: hidden;
    white-space: nowrap; /* Keep text on a single line */
    text-overflow: ellipsis; /* Add the "..." for overflow */
}

/* ======================================== */
/* === 5. Page-Specific & Layout === */
/* ======================================== */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #00ff41;
}

.dashboard-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.profile-forms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
}

.campaigns-grid,
.characters-grid,
.stats-grid,
.resources-grid,
.resources-edit,
.abilities-management {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.abilities-display-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 25px;
    }

.ability-column h4 {
    color: #ffff00;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 0, 0.3);
    padding-bottom: 5px;
}

.stats-grid,
.resources-grid,
.resources-edit,
.abilities-management {
    grid-template-columns: 1fr 1fr;
}

.current-abilities-list {
    margin-bottom: 15px;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.ability-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 5px;
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid rgba(0, 255, 65, 0.3);
    border-radius: 3px;
}

#dice-log {
    max-height: 400px;  /* Set a maximum height for the log */
    overflow-y: auto;   /* Add a vertical scrollbar only when needed */
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* User Info and Button Styling */
.dashboard-header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-header .user-info form {
    margin: 0;
}

.dashboard-header .user-info span {
    color: #00ffff;
    margin-right: 10px;
}

/* Button variants */
.btn-danger {
    border-color: #ff4444;
    color: #ff4444;
}

.btn-danger:hover {
    background: #ff4444;
    color: #000;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
}

/* Mobile responsiveness for header */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .dashboard-header .user-info {
        justify-content: center;
        gap: 8px;
    }
}

/* ======================================== */
/* === 6. Mobile Responsive (Safari Focus) === */
/* ======================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%; /* Prevents iOS font scaling in landscape */
    }

    .container {
        padding: 15px;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
    }

    .dashboard-header .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
        letter-spacing: 0.5px;
    }
    
    .profile-forms-grid {
        grid-template-columns: 1fr;
    }

    /* --- Universal Mobile Box Styling --- */
    .campaign-card,
    .character-card,
    .form-section,
    .character-section,
    .auth-form,
    .ability-section,
    .stat-block,
    .resource-block,
    .character-header,
    .game-info {
        min-width: 0;
        border-width: 2px;
        margin-bottom: 20px;
        /* Hardware acceleration hack to prevent flickering on redraw */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    /* --- Single-Column Grids --- */
    .campaigns-grid,
    .characters-grid,
    .stats-grid,
    .resources-grid,
    .resources-edit,
    .abilities-management, .abilities-display-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    /* --- Mobile Form Improvements --- */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents auto-zoom on focus in iOS */
        padding: 14px;
        border-width: 2px;
        min-height: 44px; /* Apple's recommended touch target size */
    }

    /* --- Mobile Button Containers --- */
    .auth-buttons,
    .form-actions,
    .character-actions,
    .dashboard-actions {
        display: block; /* Switch from flex to block for simple vertical stacking */
        width: 100%;
        margin-top: 25px;
    }

    .auth-buttons > *,
    .form-actions > *,
    .character-actions > *,
    .dashboard-actions > * {
        display: block;
        margin: 0 auto 15px auto; /* Center buttons and add space below */
        max-width: 320px;
    }

    .delete-section {
        margin-top: 30px;
        padding-top: 30px;
        border-top: 2px solid #ff4444;
    }
}