:root {
    --primary-color: #007bff;
    --primary-dark: #0056b3;
    --danger-color: #dc3545;
    --bg-color: #f4f6f9;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #e9ecef;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

/* Header & Navigation */
header {
    background: var(--card-bg);
    padding: 15px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border-radius: 0 0 8px 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

nav {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 10px;
}

nav a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

nav a:hover, nav a.active {
    color: var(--primary-color);
    background: rgba(0,123,255,0.1);
}

@media (min-width: 768px) {
    nav { margin-top: 0; }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #444;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px; /* Prevent zoom on mobile */
    box-sizing: border-box;
    transition: border-color 0.2s;
}

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

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.form-col {
    flex: 1;
    min-width: 250px;
}

/* Ball Inputs */
.ball-inputs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.ball-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 45px;
}

.ball-input {
    width: 40px;
    height: 40px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    outline: none;
    transition: all 0.2s;
}

.ball-input:focus {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.ball-label {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.plus-sign {
    font-size: 24px;
    color: #888;
    margin: 0 5px;
    padding-bottom: 20px; /* Align with input */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover { background-color: #5a6268; }

.btn-danger {
    background-color: var(--danger-color);
}
.btn-danger:hover { background-color: #c82333; }

.btn-block {
    display: flex;
    width: 100%;
}

/* Table */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #444;
}

/* Ball Display */
.ball-display {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.ball {
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ball.red { background: linear-gradient(135deg, #ff6b6b, #ee0909); }
.ball.blue { background: linear-gradient(135deg, #4facfe, #00f2fe); background-color: #1890ff; } /* Fallback/Gradient tweak */
.ball.blue { background: linear-gradient(135deg, #4facfe, #1890ff); }
.ball.green { background: linear-gradient(135deg, #43e97b, #38f9d7); background-color: #52c41a; }
.ball.green { background: linear-gradient(135deg, #69c0ff, #52c41a); } /* Fixed green gradient */
.ball.green { background: linear-gradient(135deg, #95de64, #52c41a); }

.ball.none { background: #e0e0e0; color: #666; }

.ball-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.attrs {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

/* Attribute Editor */
.attr-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
}
.attr-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    background: var(--card-bg);
}
.attr-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.attr-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.chip {
    display: inline-block;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 12px;
    background: #f1f1f1;
    color: #555;
}
.zodiac-section {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    background: var(--card-bg);
}
.zodiac-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.zodiac-items {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.attr-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.attr-controls select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .container { padding: 10px; }
    
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        margin-top: 15px;
    }
    
    nav a {
        white-space: nowrap;
        background: #f1f1f1;
        margin-right: 5px;
    }

    .ball-inputs {
        justify-content: space-between;
    }
    
    .ball-input-group {
        width: 13%; /* Fit 7 balls */
    }
    
    .ball-input {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        font-size: 16px;
    }
    
    .plus-sign {
        display: none; /* Hide + on mobile to save space, or make smaller */
    }

    /* Stack form actions */
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn { width: 100%; }
    
    .attr-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .zodiac-items {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid transparent;
}
.alert-success { background-color: #d4edda; color: #155724; border-left-color: #28a745; }
.alert-error { background-color: #f8d7da; color: #721c24; border-left-color: #dc3545; }

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

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
