:root {
    --primary-color: #0f172a;
    --border-color: rgba(203, 213, 225, 0.5);
    --bg-color: #f8fafc;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;

    /* Weather colors */
    --w-sec: #fef08a;
    --w-lluvia-suave: #93c5fd;
    --w-lluvia-fuerte: #3b82f6;
    --w-none: transparent;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: linear-gradient(-45deg, #e2e8f0, #cbd5e1, #e0e7ff, #f1f5f9);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    line-height: 1.5;
    padding: 2rem 1rem;
}

/* Page Container feels like a physical paper */
.page-container {
    background-color: var(--white);
    max-width: 900px;
    margin: 0 auto;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    min-height: 1122px;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Common Inputs */
.editable-input {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: inherit;
    background-color: transparent;
    transition: all 0.2s;
}

.editable-input:hover {
    background-color: #f1f5f9;
}

.editable-input:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--white);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 4px 6px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.bold-text {
    font-weight: 600;
}

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

.text-sm {
    font-size: 0.85rem;
}

.full-width {
    width: 100%;
}

textarea.auto-grow {
    resize: none;
    overflow: hidden;
    min-height: 38px;
}

/* Actions Ribbon */
.actions {
    max-width: 900px;
    margin: 0 auto 20px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.actions button {
    font-family: inherit;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.btn-print {
    background: linear-gradient(135deg, var(--primary-color), #475569);
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-print:hover {
    background: linear-gradient(135deg, #1e293b, var(--primary-color));
}

.btn-share {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-share:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.btn-logout {
    background-color: transparent !important;
    color: var(--danger) !important;
    box-shadow: none !important;
    border: 1px solid var(--danger) !important;
    padding: 6px 12px !important;
    font-size: 0.85rem !important;
}

.btn-logout:hover {
    background-color: var(--danger) !important;
    color: white !important;
}

.sync-status {
    font-size: 0.85rem;
    margin-right: 15px;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.sync-status.ok {
    color: #10b981;
}

.sync-status.syncing {
    color: #f59e0b;
}

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.login-box {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
}

/* Header Section Flex Layout */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 15px;
    gap: 15px;
}

.header-left,
.header-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.header-right {
    align-items: flex-end;
}

.header-center {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.header-title h1 {
    font-size: 1.4rem;
    color: var(--primary-color);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.1rem;
}

.header-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
}

.meta-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.meta-item label {
    width: 60px;
    text-align: right;
    margin-right: 5px;
}

.meta-item input {
    width: 80px;
}

/* Logos Upload Box */
.header-logo-box {
    width: 130px;
    height: 100px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* General Info */
.general-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.info-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.temp-input-wrapper {
    display: flex;
    align-items: center;
}

.temp-input-wrapper input {
    width: 60px;
    text-align: right;
}

/* Sections */
.section-block {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.section-title {
    font-size: 1rem;
    background-color: #cbd5e1;
    color: var(--primary-color);
    padding: 4px 10px;
    font-weight: 700;
    display: inline-block;
    border: 1px solid #94a3b8;
    margin-bottom: 10px;
}

/* Tables */
.data-table,
.weather-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.weather-table th,
.weather-table td {
    border: 1px solid #000;
    padding: 6px;
    text-align: left;
}

.data-table th {
    background-color: #e2e8f0;
    font-weight: 600;
    text-align: center;
}

.data-table td {
    vertical-align: top;
}

.btn-add {
    background-color: var(--white);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-add:hover {
    background-color: var(--accent);
    color: white;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

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

/* Weather Specifics */
.weather-table-container {
    border: 1px solid #000;
}

.weather-table {
    border: none;
}

.weather-table th,
.weather-table td {
    border-width: 1px;
}

.th-label {
    text-align: center !important;
    font-weight: 600;
    width: 25%;
}

.th-sec-lluvia {
    padding: 0 !important;
}

.estado-legend {
    display: flex;
    width: 100%;
    height: 100%;
}

.legend-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    padding: 5px;
    font-size: 0.8rem;
}

.legend-item:first-child {
    border-right: 1px solid #000;
}

.legend-item.sec {
    color: #b45309;
}

.legend-item.lluvia {
    color: #1e3a8a;
}

.legend-item i {
    font-size: 1.1rem;
}

/* Default representation */

.hours-row th {
    text-align: center;
    width: calc(75% / 12);
}

.weather-slots td {
    height: 50px;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    padding: 4px !important;
}

.w-cell {
    width: 100%;
    height: 100%;
    min-height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    color: transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px dashed #cbd5e1;
}

.w-cell:hover {
    background-color: #e2e8f0;
    transform: scale(1.05);
}

.w-cell.w-sec {
    background: linear-gradient(135deg, #fef08a, #fcd34d);
    color: #b45309;
    border: none;
    box-shadow: 0 4px 6px rgba(252, 211, 77, 0.3);
}

.w-cell.w-lluvia {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: white;
    border: none;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

.w-cell i {
    font-size: 1.2rem;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.precipitaciones-box {
    padding: 10px;
    border-top: 1px solid #000;
}

.precipitaciones-row {
    display: flex;
    margin-bottom: 5px;
    align-items: flex-start;
}

.precipitaciones-row label {
    font-size: 0.85rem;
    font-weight: 600;
    width: 110px;
    flex-shrink: 0;
    margin-top: 5px;
}

.weather-instructions {
    margin-bottom: 10px;
    color: var(--accent);
}

/* Photo Section */
.hidden {
    display: none;
}

.photo-actions {
    display: flex;
    gap: 10px;
}

.photo-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    border: 1px solid #000;
    padding: 15px;
    min-height: 200px;
}

.empty-photos {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
    opacity: 0.6;
}

.empty-photos i {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.photo-item {
    border: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #f8fafc;
}

.photo-img-wrapper {
    width: 100%;
    height: 250px;
    overflow: hidden;
    position: relative;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.photo-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-caption {
    padding: 8px;
    border-top: 1px solid #cbd5e1;
}

.signatures-section {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    padding-bottom: 30px;
}

.signature-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 250px;
    position: relative;
}

.signature-img-container {
    width: 100%;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    margin-bottom: -5px;
}

.signature-img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
    z-index: 10;
}

.signature-upload-btn {
    position: absolute;
    top: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px dashed var(--border-color);
    transition: all 0.2s;
}

.signature-upload-btn:hover {
    background: #e2e8f0;
    color: var(--accent);
}

.sign-line {
    width: 100%;
    border-bottom: 1px solid #000;
    margin-bottom: 10px;
    height: 1px;
    z-index: 1;
}

/* Layout & Calendar */
.layout-wrapper {
    display: flex;
    justify-content: center;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.calendar-sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    width: 280px;
    height: fit-content;
    position: sticky;
    top: 20px;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.calendar-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.calendar-header {
    text-align: center;
    font-weight: 700;
    margin-bottom: 0;
    text-transform: uppercase;
    color: var(--text-main);
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.btn-cal-nav {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--accent);
    padding: 5px;
    transition: all 0.2s;
}

.btn-cal-nav:hover {
    color: var(--accent-hover);
    transform: scale(1.1);
}

.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    background-color: #f1f5f9;
    color: var(--text-muted);
    position: relative;
    opacity: 0.5;
}

.cal-day.current-month {
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    opacity: 1;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cal-day.current-month:hover {
    background-color: var(--white);
    transform: scale(1.15);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.cal-day.done {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.cal-day.missed {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.cal-day i {
    position: absolute;
    bottom: -2px;
    right: 2px;
    font-size: 0.6rem;
}

.calendar-legend {
    display: flex;
    justify-content: space-around;
    font-size: 0.8rem;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.text-green {
    color: #166534;
}

.text-red {
    color: #991b1b;
}

/* Rain Chart */
.rain-chart-container {
    width: 100%;
    height: 200px;
    padding: 10px;
    border-top: 1px solid #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rain-total-label {
    font-weight: 700;
    margin-top: 10px;
    font-size: 1rem;
    color: var(--primary-color);
}

/* --- RESPONSIVE MEDIA QUERIES --- */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

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

    .calendar-sidebar {
        width: 100%;
        max-width: 400px;
        position: static;
        margin-bottom: 20px;
    }

    .page-container {
        padding: 20px 15px;
        width: 100%;
    }

    .header-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }

    .header-left,
    .header-right {
        align-items: center;
    }

    .header-meta {
        align-items: center;
        margin-top: 15px;
        flex-direction: row;
        justify-content: center;
        gap: 20px;
    }

    .general-info {
        flex-wrap: wrap;
        gap: 15px;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 10px;
        /* Move the border outside to prevent clipping when scrolled */
        border: 1px solid #000;
    }

    .data-table {
        border: none;
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        border-width: 1px;
    }

    .weather-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .weather-table {
        min-width: 600px;
    }

    .photos-grid {
        grid-template-columns: 1fr;
    }

    .photo-actions {
        flex-direction: column;
        width: 100%;
    }

    .signatures-section {
        flex-direction: column;
        gap: 40px;
        align-items: center;
    }
}

/* --- PRINT MEDIA QUERY --- */
/* This transforms the beautiful UI into a standard form view for PDF */
@media print {
    body {
        background-color: white;
        padding: 0;
        margin: 0;
    }

    .page-container {
        box-shadow: none;
        padding: 0;
        margin: 0;
        max-width: 100%;
        width: 100%;
        border-radius: 0;
    }

    .noprint {
        display: none !important;
    }

    .rain-mins-print {
        display: block !important;
        margin-top: 2px;
        color: #000;
    }


    .editable-input {
        border: none;
        background: transparent !important;
        resize: none;
        padding: 0;
    }

    /* Ensure borders print black */
    .data-table th,
    .weather-table th,
    .weather-table td,
    .data-table td {
        border-color: #000 !important;
    }

    .section-title {
        border-color: #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background-color: #e2e8f0 !important;
    }

    /* Print color adjustments for weather box */
    .w-cell {
        border-radius: 0;
        box-shadow: none !important;
        border: none;
    }

    .w-cell.w-sec {
        background: #fef08a !important;
        /* solid fallback */
        color: #b45309 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .w-cell.w-lluvia {
        background: #3b82f6 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .weather-slots td {
        padding: 0 !important;
        height: 35px;
    }

    .w-cell i {
        font-size: 1rem;
    }

    /* Forcing elements not to break across pages awkwardly */
    .section-block {
        page-break-inside: avoid;
        margin-bottom: 10px !important;
        /* Compress margins to ensure it fits on one page */
    }

    .section-title {
        margin-bottom: 5px !important;
    }

    .header-section {
        margin-bottom: 10px !important;
        padding-bottom: 10px !important;
    }

    .page-break-before {
        page-break-before: always;
    }

    .photo-item {
        page-break-inside: avoid;
        border-color: #000;
    }

    .photo-img-wrapper {
        display: block !important;
        height: auto !important;
        background-color: transparent !important;
        text-align: center;
    }

    .photo-item img {
        display: inline-block !important;
        max-width: 100% !important;
        max-height: 250px !important;
        object-fit: contain !important;
        visibility: visible !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .signature-img {
        display: inline-block !important;
        visibility: visible !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .signature-upload-btn {
        display: none !important;
    }

    tr {
        page-break-inside: avoid;
    }

    .textarea-container textarea {
        border: 1px solid #000 !important;
        border-radius: 4px;
        padding: 10px !important;
        min-height: 100px !important;
        box-sizing: border-box;
    }

    .textarea-container textarea.description-area {
        min-height: 180px !important;
    }
}

.rain-mins-input {
    width: 32px;
    margin: 2px auto 0 auto;
    text-align: center;
    font-size: 0.65rem;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 3px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-weight: bold;
    display: block;
}

.rain-mins-input:focus {
    background: white;
    color: black;
    border-color: #3b82f6;
    outline: none;
}

.rain-mins-input::-webkit-inner-spin-button, 
.rain-mins-input::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
