/* Space-themed CSS for Star Effort Chart */

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

/* Page background lives on the root element to avoid Safari stacking quirks */
html {
    min-height: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #4a69bd 100%);
}

body {
    font-family: 'Arial', sans-serif;
    
    /* Background moved to html; keep body transparent for star layer */
    background: transparent;
    
    min-height: 100vh;
    color: white;
    position: relative;
    overflow-x: hidden;
}

/* Star field background with Safari fallback */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Place stars above the html background but below content */
    opacity: 0.7;
    pointer-events: none;
    
    /* Primary: SVG-based stars (works in all browsers) */
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="120" viewBox="0 0 200 120"><circle cx="20" cy="30" r="1" fill="white" opacity="0.8"/><circle cx="40" cy="70" r="1.2" fill="white" opacity="0.7"/><circle cx="90" cy="40" r="0.8" fill="white" opacity="0.6"/><circle cx="130" cy="80" r="0.6" fill="white" opacity="0.5"/><circle cx="160" cy="30" r="1" fill="white" opacity="0.8"/><circle cx="180" cy="60" r="0.9" fill="white" opacity="0.6"/><circle cx="60" cy="100" r="0.7" fill="white" opacity="0.7"/><circle cx="120" cy="20" r="0.8" fill="white" opacity="0.6"/><circle cx="10" cy="80" r="0.5" fill="white" opacity="0.4"/><circle cx="170" cy="90" r="0.6" fill="white" opacity="0.5"/></svg>');
    background-size: 200px 120px;
    background-repeat: repeat;
    
    /* Animation */
    animation: sparkle 5s linear infinite;
}

/* Ensure page content sits above the star layer */
body > * {
    position: relative;
    z-index: 1;
}

/* Removed optional gradient-based stars for simplicity and cross-browser stability */

@keyframes sparkle {
    0% { 
        -webkit-transform: translateX(0);
        transform: translateX(0); 
    }
    100% { 
        -webkit-transform: translateX(200px);
        transform: translateX(200px); 
    }
}



.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #ffd700, #ffeb3b, #fff59d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2em;
    margin-bottom: 20px;
    opacity: 0.9;
}

.add-task-btn {
    display: inline-block;
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.add-task-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
    background: linear-gradient(45deg, #ff5252, #f44336);
}

/* Header buttons container */
.header-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
}

/* Mission Control button */
.manage-missions-btn {
    display: inline-block;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.manage-missions-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(45deg, #5a67d8, #6b46c1);
}

/* Navigation buttons for other pages */
.navigation-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.nav-btn {
    display: inline-block;
    background: linear-gradient(45deg, #4ade80, #22c55e);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(74, 222, 128, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 222, 128, 0.6);
    background: linear-gradient(45deg, #22c55e, #16a34a);
}

/* Logout button */
.logout-btn {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-left: auto;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
    background: linear-gradient(45deg, #dc2626, #b91c1c);
}

.main-content {
    display: grid;
    gap: 30px;
}

.child-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.child-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.child-header h2 {
    font-size: 2em;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    color: #ffd700;
}

.star-total {
    background: linear-gradient(45deg, #ffd700, #ffeb3b);
    color: #1e3c72;
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.task-list table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.task-list th {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.task-list td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s ease;
}

.task-list tr:hover td {
    background: rgba(255, 255, 255, 0.1);
}

.task-list tr:last-child td {
    border-bottom: none;
}

/* Actions column styling */
.task-list th:last-child,
.task-list td:last-child {
    width: 120px;
    text-align: center;
}

/* Delete/Abort Mission button styling */
.delete-btn {
    background: linear-gradient(45deg, #ff4757, #ff3742);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.delete-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(45deg, #ff3742, #ff2f3a);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.5);
}

.delete-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(255, 71, 87, 0.4);
}

.no-tasks {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.2em;
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    opacity: 0.8;
}

/* Add Task Page Styles */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #ffd700;
    font-size: 1.1em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #1e3c72;
    font-size: 1em;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    background: rgba(255, 255, 255, 1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(45deg, #4caf50, #45a049);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

.btn-secondary {
    background: linear-gradient(45deg, #757575, #616161);
    color: white;
    box-shadow: 0 4px 15px rgba(117, 117, 117, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(117, 117, 117, 0.6);
}

/* ============= MISSION MANAGEMENT STYLES ============= */

/* Mission form section */
.mission-form-section {
    margin-bottom: 40px;
}

.mission-form-section h2 {
    color: #ffd700;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Missions list section */
.missions-list-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.missions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.missions-header h2 {
    color: #ffd700;
    font-size: 1.8em;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    margin: 0;
}

.missions-stats {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 15px;
    font-weight: bold;
}

.missions-stats span {
    color: #e2e8f0;
}

/* Mission preview styles */
.mission-preview {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    border: 2px solid rgba(74, 222, 128, 0.3);
    margin-top: 10px;
}

.mission-details {
    color: #e2e8f0;
}

.mission-details strong {
    color: #ffd700;
    display: block;
    margin-bottom: 5px;
}

#selected-mission-description {
    font-style: italic;
    margin-bottom: 5px;
}

#selected-mission-reward {
    color: #4ade80;
    font-weight: bold;
}

/* Mission status badges */
.status-active {
    background: linear-gradient(45deg, #4ade80, #22c55e);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
}

.status-inactive {
    background: linear-gradient(45deg, #6b7280, #4b5563);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
}

/* Small action buttons */
.btn-small {
    padding: 4px 8px;
    border: none;
    border-radius: 8px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 2px;
    min-width: auto;
}

.btn-edit {
    background: linear-gradient(45deg, #3b82f6, #2563eb);
    color: white;
}

.btn-edit:hover {
    background: linear-gradient(45deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
}

.btn-toggle {
    background: linear-gradient(45deg, #f59e0b, #d97706);
    color: white;
}

.btn-toggle:hover {
    background: linear-gradient(45deg, #d97706, #b45309);
    transform: translateY(-1px);
}

.btn-delete {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    color: white;
}

.btn-delete:hover {
    background: linear-gradient(45deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2em;
    }
    
    .child-header {
        text-align: center;
        flex-direction: column;
    }
    
    .child-header h2 {
        font-size: 1.5em;
    }
    
    .task-list table {
        font-size: 0.9em;
    }
    
    .task-list th,
    .task-list td {
        padding: 8px 10px;
    }
    
    .task-list th:last-child,
    .task-list td:last-child {
        width: 80px;
    }
    
    .delete-btn {
        padding: 4px 8px;
        font-size: 0.75em;
    }
    
    .form-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .header-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .add-task-btn,
    .manage-missions-btn {
        width: 100%;
        max-width: 250px;
        text-align: center;
    }
    
    .navigation-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .missions-header {
        text-align: center;
        flex-direction: column;
        gap: 10px;
    }
    
    .missions-stats {
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .btn-small {
        padding: 6px 8px;
        font-size: 0.7em;
        margin: 1px;
    }
}

/* ============= LOADING STATES ============= */

.loading-state {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 15px;
    margin: 1rem 0;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #4ade80;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-state p {
    color: #4ade80;
    font-weight: bold;
    margin: 0;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Loading state responsive design */
@media (max-width: 480px) {
    .loading-state {
        padding: 1.5rem;
        margin: 0.5rem 0;
    }
    
    .loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
    
    .loading-state p {
        font-size: 1rem;
    }
}