/* ============ Reset & Base ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ============ Screens ============ */
.screen {
    display: none;
    height: 100%;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* ============ Login Screen ============ */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-container {
    text-align: center;
    padding: 2rem;
}

.login-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.tagline {
    color: #888;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* ============ Loading Screen ============ */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.loading-container {
    text-align: center;
}

.loading-container p {
    color: #888;
    margin-top: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #3a3a5a;
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ Header ============ */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #16213e;
    border-bottom: 1px solid #2a2a4a;
    min-height: 60px;
}

#header-title {
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.header-btn {
    background: none;
    border: none;
    color: #4a9eff;
    font-size: 1rem;
    padding: 0.5rem;
    cursor: pointer;
    min-width: 50px;
}

.header-btn.hidden {
    visibility: hidden;
}

#back-btn {
    font-size: 1.5rem;
    text-align: left;
}

#settings-btn {
    text-align: right;
    font-size: 1.25rem;
}

/* ============ Content Area ============ */
#content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 80px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* ============ Cards ============ */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.card {
    background: #242442;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.card:active {
    background: #2a2a52;
    transform: scale(0.98);
}

.card-main {
    flex: 1;
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.card-subtitle {
    color: #888;
    font-size: 0.9rem;
}

.card-edit-btn {
    background: none;
    border: none;
    color: #4a9eff;
    font-size: 1.2rem;
    padding: 0.5rem;
    cursor: pointer;
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state.small {
    padding: 1.5rem 1rem;
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.empty-state .hint {
    font-size: 0.9rem;
    color: #555;
}

.empty-hint {
    color: #555;
    font-size: 0.9rem;
    font-style: italic;
}

/* ============ Add Button ============ */
.add-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.add-btn:active {
    background: #3a8eef;
}

/* ============ Info Card (Student Profile, Report Detail) ============ */
.info-card {
    background: #242442;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #3a3a5a;
}

.info-header h2 {
    font-size: 1.3rem;
}

.edit-btn {
    background: none;
    border: none;
    color: #4a9eff;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
}

.info-row {
    margin-bottom: 0.75rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    display: block;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1rem;
    color: #eee;
    white-space: pre-wrap;
}

/* ============ Section Title ============ */
.section-title {
    font-size: 0.9rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

/* ============ Action Buttons (Report Detail) ============ */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-btn {
    flex: 1;
    padding: 0.875rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:not(.danger) {
    background: #4a9eff;
    color: #fff;
}

.action-btn.danger {
    background: #ff4a6a;
    color: #fff;
}

/* ============ Settings View ============ */
.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

/* Account */
.account-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.account-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    background: #3a3a5a;
}

.account-details {
    flex: 1;
}

.account-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.account-email {
    font-size: 0.9rem;
    color: #888;
}

.logout-btn {
    width: 100%;
}

/* Settings Items (Schools list) */
.settings-item {
    display: flex;
    align-items: center;
    background: #242442;
    border-radius: 10px;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
}

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-item-main {
    flex: 1;
}

.settings-item-name {
    display: block;
    font-weight: 500;
}

.settings-item-sub {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.125rem;
}

.settings-item-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    color: #4a9eff;
    font-size: 1.1rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:active {
    background: rgba(74, 158, 255, 0.1);
}

.icon-btn.danger {
    color: #ff4a6a;
}

.icon-btn.danger:active {
    background: rgba(255, 74, 106, 0.1);
}

/* Instruments */
.instruments-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    min-height: 32px;
}

.instrument-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: #3a3a5a;
    color: #eee;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.tag-remove {
    background: none;
    border: none;
    color: #888;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-left: 0.25rem;
}

.tag-remove:hover {
    color: #ff4a6a;
}

.add-instrument-row {
    display: flex;
    gap: 0.5rem;
}

.add-instrument-row input {
    flex: 1;
    padding: 0.75rem;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
}

.add-instrument-row input:focus {
    outline: none;
    border-color: #4a9eff;
}

.add-instrument-row input::placeholder {
    color: #555;
}

.small-btn {
    width: 44px;
    height: 44px;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.small-btn:active {
    background: #3a8eef;
}

/* Subscription */
.subscription-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #3a3a5a;
}

.subscription-plan {
    display: flex;
    flex-direction: column;
}

.plan-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #4a9eff;
}

.student-count {
    font-size: 0.9rem;
    color: #888;
}

.subscription-details {
    margin-bottom: 1rem;
}

.subscription-details p {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 0.25rem;
}

#upgrade-btn.highlight {
    background: linear-gradient(135deg, #4a9eff 0%, #7c3aed 100%);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* ============ Bottom Toolbar ============ */
#bottom-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: #16213e;
    border-top: 1px solid #2a2a4a;
    padding: 0.5rem 0;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.toolbar-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
}

.toolbar-btn:active {
    color: #4a9eff;
}

.toolbar-icon {
    font-size: 1.5rem;
}

.toolbar-label {
    font-size: 0.75rem;
}

/* ============ Slide Panels (Tuner/Metronome) ============ */
.slide-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    max-height: 70vh;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.slide-panel.active {
    transform: translateY(0);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #2a2a4a;
}

.panel-header h2 {
    font-size: 1.2rem;
}

.close-panel-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.panel-content {
    padding: 1.5rem;
}

/* ============ Tuner ============ */
#tuner-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

#tuner-note {
    font-size: 4rem;
    font-weight: 700;
    color: #4a9eff;
}

#tuner-frequency {
    font-size: 1.2rem;
    color: #888;
    margin-bottom: 1rem;
}

#tuner-meter {
    height: 8px;
    background: #2a2a4a;
    border-radius: 4px;
    margin: 1rem auto;
    max-width: 250px;
    position: relative;
}

#tuner-needle {
    position: absolute;
    top: -4px;
    left: 50%;
    width: 4px;
    height: 16px;
    background: #4a9eff;
    border-radius: 2px;
    transform: translateX(-50%);
}

#tuner-status {
    color: #666;
    font-size: 0.9rem;
}

/* ============ Metronome ============ */
#metronome-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

#metronome-bpm {
    font-size: 4rem;
    font-weight: 700;
    color: #4a9eff;
}

#metronome-label {
    font-size: 1rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#metronome-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.bpm-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #242442;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bpm-btn:active {
    background: #3a3a5a;
}

#bpm-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #2a2a4a;
    border-radius: 4px;
    outline: none;
}

#bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4a9eff;
    cursor: pointer;
}

/* ============ Subdivision Controls ============ */
#subdivision-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.subdivision-btn {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #242442;
    border: 2px solid transparent;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.subdivision-btn:active {
    background: #3a3a5a;
}

.subdivision-btn.active {
    background: #2a3a5a;
    border-color: #4a9eff;
    color: #4a9eff;
}

#subdivision-label {
    text-align: center;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============ Modals ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 200;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    width: 100%;
    max-height: 90vh;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    overflow-y: auto;
}

.modal-small {
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    margin: auto;
    padding: 1.5rem;
    text-align: center;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #2a2a4a;
}

.modal-header h2 {
    font-size: 1.2rem;
}

.close-modal-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

/* ============ Forms ============ */
form {
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem;
    background: #242442;
    border: 1px solid #3a3a5a;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #4a9eff;
}

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

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #555;
}

/* ============ Buttons ============ */
.primary-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:active {
    background: #3a8eef;
}

.secondary-btn {
    padding: 0.875rem 1.5rem;
    background: #3a3a5a;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.secondary-btn:active {
    background: #4a4a6a;
}

.danger-btn {
    padding: 0.875rem 1.5rem;
    background: #ff4a6a;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-buttons button {
    flex: 1;
}

#confirm-message {
    font-size: 1.1rem;
    color: #eee;
}

/* ============ Safe Area (iOS) ============ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #content-area {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
}
