:root {
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #3b82f6;
    --border: rgba(255, 255, 255, 0.5);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 0.05) 0, transparent 50%), radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 0.05) 0, transparent 50%), radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 0.05) 0, transparent 50%);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

/* Layout */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Accordion */
details.accordion-card summary {
    list-style: none;
    /* Hide default arrow */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: 0.25rem;
    /* Make tap target slightly larger */
}

details.accordion-card summary::-webkit-details-marker {
    display: none;
}

details.accordion-card summary h3 {
    margin: 0;
}

details.accordion-card summary::after {
    content: "▼";
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

details.accordion-card[open] summary::after {
    transform: rotate(180deg);
}

.accordion-content {
    margin-top: 1rem;
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.app-header {
    background-color: var(--primary);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    transition: background-color 0.3s ease;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    flex-grow: 1;
    text-align: center;
}

.btn-back,
.btn-action {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* Main Content */
.app-content {
    padding: 1.5rem 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Dashboard */
.dashboard-header {
    text-align: center;
    margin-bottom: 1rem;
}

.dashboard-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.dashboard-header p {
    color: var(--text-muted);
}

.child-list {
    display: grid;
    gap: 1rem;
}

.child-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border-left: 6px solid var(--primary);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    transition: var(--transition);
}

.child-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.child-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-main);
    flex-grow: 1;
}

.child-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.child-name {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Buttons & Forms */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.delete-btn:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.875rem;
}

input[type="text"],
input[type="password"] {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.color-picker {
    width: 100%;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius);
}

/* Timetable Layout */
/* Matrix Timetable Layout */
.timetable-matrix-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    overflow-x: auto;
    /* Just in case for extremely small screens */
}

.timetable-grid {
    display: grid;
    grid-template-columns: 45px repeat(5, 1fr);
    gap: 4px;
    min-width: 300px;
}

.grid-header-corner {
    /* empty */
}

.grid-header-day {
    font-weight: 700;
    text-align: center;
    padding: 0.5rem 0;
    color: var(--text-main);
    border-bottom: 2px solid #e5e7eb;
    font-size: 0.9rem;
}

.grid-period-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    padding-right: 6px;
    border-right: 1px solid #e5e7eb;
}

.period-num {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.period-time {
    font-size: 0.65rem;
    color: #9ca3af;
    line-height: 1;
}

.grid-lesson-cell {
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 50px;
}

.matrix-lesson-card {
    flex-grow: 1;
    background: white;
    border-radius: 8px;
    border-top: 3px solid transparent;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    width: 100%;
}

.matrix-lesson-empty {
    flex-grow: 1;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    width: 100%;
}

.matrix-subject-name {
    font-weight: 700;
    font-size: 0.75rem;
    line-height: 1.1;
    word-break: break-word;
}

/* Specific edit mode styles for matrix */
.edit-card {
    position: relative;
    padding-bottom: 20px;
}

.delete-form-inline {
    position: absolute;
    bottom: 2px;
    right: 2px;
}

.matrix-delete-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0.5;
}

.matrix-delete-btn:hover {
    opacity: 1;
}

.matrix-add-form {
    width: 100%;
    height: 100%;
    display: flex;
}

.matrix-subject-select {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    text-align-last: center;
}

/* Edit Mode */
.subject-manager {
    margin-bottom: 1.5rem;
}

.form-group-inline {
    display: flex;
    gap: 0.5rem;
}

.form-group-inline input[type="text"] {
    flex-grow: 1;
}

.form-group-inline input[type="color"] {
    width: 48px;
}

.subject-select {
    width: 100%;
    height: 100%;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    color: var(--text-muted);
    padding: 0 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.subject-select:hover {
    background: rgba(0, 0, 0, 0.02);
}

.period-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    line-height: 1.2;
    margin-top: 4px;
    font-weight: 400;
}

.period-number {
    font-weight: 600;
    color: var(--text-muted);
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: transform 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.5;
}

.info-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    margin-top: 1rem;
    display: block;
}

.matrix-lesson-card {
    cursor: pointer;
}