/* School Theme Variables */
:root {
    --primary-color: #2c3e50;
    /* Navy Blue */
    --secondary-color: #27ae60;
    /* Chalkboard Green */
    --accent-color: #f39c12;
    /* Pencil Yellow */
    --bg-color: #ecf0f1;
    /* Paper White */
    --text-color: #2c3e50;
    --card-bg: #ffffff;
    --danger-color: #e74c3c;
    /* Red Ink */
    --success-bg: #d4efdf;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: 40px;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--primary-color);
    margin-bottom: 0.5em;
    font-weight: 700;
}

.text-muted {
    color: #7f8c8d;
}

.text-danger {
    color: var(--danger-color);
}

.text-success {
    color: var(--secondary-color);
}

.text-white {
    color: white;
}

.text-center {
    text-align: center;
}

.text-end {
    text-align: end;
}

.fw-bold {
    font-weight: bold;
}

.fs-4 {
    font-size: 1.5rem;
}

.fs-2 {
    font-size: 2rem;
}

/* Utilities */
.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.justify-content-between {
    justify-content: space-between;
}

.justify-content-center {
    justify-content: center;
}

.justify-content-end {
    justify-content: flex-end;
}

.align-items-center {
    align-items: center;
}

.align-items-start {
    align-items: flex-start;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

.w-100 {
    width: 100%;
}

.h-100 {
    height: 100%;
}

.d-none {
    display: none !important;
}

.position-relative {
    position: relative;
}

.m-0 {
    margin: 0;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.me-2 {
    margin-right: 0.5rem;
}

.me-3 {
    margin-right: 1rem;
}

.p-3 {
    padding: 1rem;
}

.p-4 {
    padding: 1.5rem;
}

.p-0 {
    padding: 0;
}

.bg-light {
    background-color: #f8f9fa;
}

.shadow {
    box-shadow: var(--shadow);
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.rounded {
    border-radius: var(--radius);
}

.border {
    border: 1px solid #dee2e6;
}

.border-0 {
    border: 0 !important;
}

/* Navbar */
.navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-content {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.nav-auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: white;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #bdc3c7;
    /* Notebook line color */
}

/* View Section Animation */
.view-section {
    display: none;
    animation: slideUp 0.4s ease-out;
}

.view-active {
    display: block;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Form */
.login-card {
    max-width: 400px;
    margin: 4rem auto;
    border-top: 4px solid var(--accent-color);
}

/* Inputs */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    font-size: 1rem;
    background: #fdfdfd;
    transition: border-color 0.2s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background-color: #219150;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-link {
    background: none;
    color: var(--primary-color);
    padding: 0;
    text-decoration: underline;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.875rem;
}

.w-100 {
    width: 100%;
}

/* Dashboard Elements */
.balance-card {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    text-align: center;
    border: none;
    position: relative;
    overflow: hidden;
    padding: 2rem;
}

.balance-card .btn {
    position: relative;
    z-index: 10;
}

.balance-card::after {
    content: "₽";
    position: absolute;
    right: -20px;
    bottom: -40px;
    font-size: 15rem;
    opacity: 0.05;
    font-weight: bold;
    pointer-events: none;
    z-index: 1;
}

.balance-card h1,
.balance-card h2,
.balance-card h3,
.balance-card h4,
.balance-card h5,
.balance-card h6 {
    color: white;
}

.goal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card-goal {
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-goal:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #ecf0f1;
}

/* Action Icon Buttons - smaller and less intrusive */
.action-icon-btn {
    padding: 2px 6px !important;
    font-size: 0.7rem !important;
    min-width: 24px !important;
    height: 24px !important;
    line-height: 1 !important;
    border-width: 1px !important;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.action-icon-btn:hover {
    opacity: 1;
}

.action-icon-btn.btn-outline {
    border-color: #bdc3c7 !important;
    color: #7f8c8d !important;
}

.action-icon-btn.btn-outline:hover {
    background: #bdc3c7 !important;
    color: white !important;
}

.action-icon-btn.btn-outline-danger {
    border-color: #e6b0aa !important;
    color: #c0392b !important;
}

.action-icon-btn.btn-outline-danger:hover {
    background: #e6b0aa !important;
    color: white !important;
}

.action-icon-btn.btn-link {
    color: #7f8c8d !important;
    text-decoration: none !important;
    opacity: 0.6;
}

.action-icon-btn.btn-link:hover {
    color: var(--primary-color) !important;
    opacity: 1;
}

/* Excluded Parent Styling */
.parent-excluded {
    opacity: 0.5;
}

.parent-excluded strong {
    text-decoration: line-through;
}

.btn-outline-danger {
    background: transparent;
    border: 2px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background: var(--danger-color);
    color: white;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-secondary {
    background: #95a5a6;
    color: white;
}

.badge-success {
    background: var(--secondary-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

/* Progress Bar */
.progress-container {
    background: #e0e0e0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin: 10px 0;
    width: 100%;
}

.progress-bar {
    height: 100%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    transition: width 0.5s ease;
}

/* Modals (Native Dialog) */
dialog {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 90%;
    margin: auto;
    background: white;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h1,
.modal-header h2,
.modal-header h3,
.modal-header h4,
.modal-header h5,
.modal-header h6 {
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #ecf0f1;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

th {
    background-color: #f8f9fa;
    color: var(--primary-color);
    font-weight: 600;
}

tr:hover {
    background-color: #f1f2f6;
}

.status-paid {
    color: var(--secondary-color);
    background: var(--success-bg);
    border-radius: 4px;
    padding: 4px 8px;
    text-align: center;
}

.status-unpaid {
    color: var(--danger-color);
    background: #fadbd8;
    border-radius: 4px;
    padding: 4px 8px;
    text-align: center;
}

.status-excluded {
    color: #95a5a6;
    background: #ecf0f1;
    border-radius: 4px;
    padding: 4px 8px;
    text-align: center;
}

/* Alert */
.alert {
    padding: 1rem;
    border-radius: 8px;
    background: #d6eaf8;
    color: #2980b9;
    border: 1px solid #a9cce3;
}

/* Closed Stamp */
.closed-stamp {
    position: absolute;
    transform: rotate(-15deg);
    border: 3px solid var(--danger-color);
    color: var(--danger-color);
    padding: 8px 15px;
    font-weight: 900;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.9);
    z-index: 5;
    pointer-events: none;
}

.closed-goal {
    filter: grayscale(0.8);
    opacity: 0.8;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .navbar-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .goal-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
        display: flex;
        margin-bottom: 0.5rem;
    }

    .btn-sm {
        width: auto;
        display: inline-flex;
    }

    .nav-actions {
        width: 100%;
        justify-content: center;
    }

    .d-flex-mobile-col {
        flex-direction: column !important;
    }

    .w-100-mobile {
        width: 100% !important;
    }

    .align-items-start-mobile {
        align-items: flex-start !important;
    }

    .mb-mobile-2 {
        margin-bottom: 0.5rem !important;
    }

    /* Goal Actions Grid - Mobile */
    .goal-actions-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }

    .goal-actions-grid .btn {
        width: 100%;
        margin-bottom: 0;
        height: 100%; /* Equal height */
    }

    /* Close button full width */
    #btn-close-goal {
        grid-column: span 2;
    }
}

/* Goal Actions Grid - Desktop */
.goal-actions-grid {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Photo Gallery */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.photo-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.photo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.photo-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.photo-info {
    padding: 0.75rem;
}

.photo-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Upload Preview */
.upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
}

.upload-preview-item {
    text-align: center;
}

.upload-preview-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #bdc3c7;
}

.upload-preview-name {
    display: block;
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 15px;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev {
    left: 30px;
}

.lightbox-next {
    right: 30px;
}

/* Sortable Table Headers */
.sortable-th {
    user-select: none;
    position: relative;
}

.sortable-th:hover {
    background-color: #e9ecef;
}

.sort-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.8rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.sortable-th:hover .sort-icon {
    opacity: 1;
}