/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #374151;
    background-color: #f9fafb;
    min-height: 100vh;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .container {
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 2rem;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-icon {
    font-size: 2rem;
    color: #2563eb;
}

.loading-text {
    font-size: 1.125rem;
    color: #6b7280;
}

/* Error Screen */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.error-content {
    max-width: 28rem;
    width: 100%;
}

.error-actions {
    margin-top: 1rem;
    text-align: center;
}

/* Alert Component */
.alert {
    position: relative;
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    padding: 1rem;
    font-size: 0.875rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: start;
}

.alert-destructive {
    color: #dc2626;
    background-color: #ffffff;
    border-color: #dc2626;
}

.alert-destructive .alert-description {
    color: rgba(220, 38, 38, 0.9);
}

.alert i {
    width: 1rem;
    height: 1rem;
    margin-top: 0.125rem;
}

.alert-title {
    grid-column: 2;
    line-height: 1;
    min-height: 1rem;
    font-weight: 500;
    letter-spacing: -0.025em;
}

.alert-description {
    grid-column: 2;
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Button Component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    outline: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    padding: 0.5rem 1rem;
    height: 2.25rem;
}

.btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn-outline {
    border: 1px solid #d1d5db;
    background-color: transparent;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    color: #374151;
}

.btn-outline:hover:not(:disabled) {
    background-color: #f3f4f6;
    color: #111827;
}

.btn-icon {
    width: 2.25rem;
    padding: 0;
}

.btn i {
    pointer-events: none;
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
}

/* Header */
.header {
    background-color: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e5e7eb;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon {
    background-color: #2563eb;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: #ffffff;
    font-size: 1.5rem;
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.25rem;
}

.header-text p {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Card Component */
.card {
    background-color: #ffffff;
    color: #374151;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.card-header {
    display: grid;
    grid-template-rows: auto auto;
    align-items: start;
    gap: 0.375rem;
    padding-bottom: 0.5rem;
}

.stats-grid .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    padding-bottom: 0.5rem;
}

.card-title {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1;
}

.card-description {
    color: #6b7280;
    font-size: 0.875rem;
}

.card-content {
    padding: 0;
}

.stats-grid .card-header i {
    width: 1rem;
    height: 1rem;
    color: #6b7280;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-description {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Selection Card */
.selection-card {
    margin-bottom: 2rem;
}

.selection-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.selection-dropdowns {
    display: flex;
    gap: 0.5rem;
}

/* Select Component */
.select {
    display: flex;
    align-items: center;
    justify-content: between;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    background-color: transparent;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    outline: none;
    height: 2.25rem;
    min-width: 8rem;
}

.select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.select:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#month-select {
    width: 8.75rem;
}

#year-select {
    width: 6.25rem;
}

/* Calendar */
.calendar-content {
    padding: 1.5rem;
}

.calendar-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.calendar-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1f2937;
}

.calendar-grid {
    width: 100%;
    max-width: 96rem;
    margin: 0 auto;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.calendar-weekday {
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    color: #6b7280;
    background-color: #f3f4f6;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
}

.calendar-day {
    min-height: 7.5rem;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem;
    transition: box-shadow 0.2s;
}

.calendar-day:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.calendar-day.invisible {
    visibility: hidden;
}

.calendar-day-number {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: #374151;
}

.calendar-day-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* No Data Message */
.no-data-message {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.no-data-message .alert {
    max-width: 28rem;
}

/* Badge Component */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    width: 100%;
    white-space: nowrap;
    flex-shrink: 0;
    gap: 0.25rem;
    transition: all 0.2s;
    overflow: hidden;
}

.badge-default {
    border-color: transparent;
    background-color: #dc2626;
    color: #ffffff;
}

.badge-secondary {
    border-color: transparent;
    background-color: #111827;
    color: #ffffff;
}

.badge-outline {
    color: #374151;
    border-color: #6b7280;
    background-color: #ffffff;
}

.badge-destructive {
    border-color: transparent;
    background-color: #d1d5db;
    color: #ffffff;
}

.badge-success {
    border-color: transparent;
    background-color: #16a34a;
    color: #ffffff;
}

.calendar-observation {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.5rem;
    padding: 0.25rem;
    background-color: #fef3c7;
    border-radius: 0.25rem;
    border-left: 2px solid #f59e0b;
}

/* Legend */
.legend-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .legend-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .legend-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
}

.legend-1 {
    background-color: #dc2626;
}

.legend-2 {
    background-color: #111827;
}

.legend-3 {
    border: 2px solid #9ca3af;
    background-color: #6b7280;
}

.legend-4 {
    background-color: #d1d5db;
}

.legend-5 {
    background-color: #16a34a;
}

.legend-item span {
    font-size: 0.875rem;
}

.legend-note {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 0.25rem;
}

.legend-note p {
    font-size: 0.875rem;
    color: #374151;
}

/* Footer */
.footer {
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    margin-top: 3rem;
}

.footer-content {
    text-align: center;
    color: #6b7280;
    padding: 1.5rem 0;
}

.footer-content p {
    margin-bottom: 0.25rem;
}

.footer-subtitle {
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .selection-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .selection-dropdowns {
        flex-direction: column;
        width: 100%;
    }

    .select {
        width: 100%;
    }

    .calendar-day {
        min-height: 5rem;
        font-size: 0.75rem;
    }

    .calendar-day-number {
        font-size: 1rem;
    }

    .badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.25rem;
    }
}

/* Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.fa-spin {
    animation: spin 1s linear infinite;
}


/* Export Button Styles */
.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover:not(:disabled) {
    background-color: #1d4ed8;
}

/* Weekly Export Template Styles */
#export-template {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1080px; /* Standard width for sharing */
    background-color: #ffffff;
    padding: 40px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.export-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 20px;
}

.export-header h1 {
    font-size: 32px;
    color: #111827;
    margin: 0;
}

.export-header p {
    font-size: 20px;
    color: #4b5563;
    margin: 5px 0 0 0;
}

.export-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.export-day-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.export-day-header {
    background-color: #f3f4f6;
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.export-day-name {
    font-weight: 700;
    font-size: 16px;
    color: #374151;
}

.export-day-date {
    font-size: 14px;
    color: #6b7280;
}

.export-day-body {
    padding: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
}

.export-inspector {
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    color: #ffffff;
    font-weight: 500;
    text-align: center;
}

.export-legend {
    margin-top: 20px;
    padding: 20px;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.export-legend-title {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 15px;
    color: #111827;
}

.export-legend-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.export-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.export-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

@media (max-width: 640px) {
    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    .btn-primary, .btn-outline {
        width: 100%;
    }
}

/* Export Observation Styles */
.export-observation {
    font-size: 12px;
    padding: 6px;
    margin-top: 6px;
    background-color: #fef3c7;
    color: #6b7280;
    border-left: 2px solid #f59e0b;
    border-radius: 3px;
    line-height: 1.3;
}

.export-legend-note {
    margin-top: 12px;
    padding: 10px;
    background-color: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
}

.export-legend-note p {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
}
