/* ===========================
   CSS Custom Properties (Theming)
   =========================== */
:root {
    /* Primary Colors - Bright, Modern & Professional */
    --color-primary: #aae4ef;
    /* Light cyan - bright and modern */
    --color-primary-light: #4169E1;
    /* Royal blue - accent shade */
    --color-accent: #00CED1;
    /* Dark turquoise - modern accent */
    --color-accent-light: #40E0D0;
    /* Turquoise - lighter accent */
    --color-success: #32CD32;
    /* Lime green - bright and clear */
    --color-success-light: #98FB98;
    /* Pale green - lighter variant */
    --color-warning: #FFD700;
    /* Gold - warm and attention-grabbing */
    --color-danger: #FF6347;
    /* Tomato red - clear danger indicator */
    --color-danger-light: #FF7F50;
    /* Coral - lighter red */

    /* Neutrals - Light and Airy */
    --color-bg: #f5f8fd;
    /* Very light gray background */
    --color-bg-secondary: #FFFFFF;
    /* Pure white */
    --color-border: #D3D3D3;
    /* Light gray borders */
    --color-text: #1C1C1C;
    /* Almost black text */
    --color-text-secondary: #666666;
    /* Medium gray text */
    --color-text-light: #FFFFFF;
    /* White text */

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Z-index */
    --z-base: 1;
    --z-dropdown: 100;
    --z-modal: 1000;
}

/* ===========================
   Global Styles
   =========================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   Container & Layout
   =========================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===========================
   Header
   =========================== */
.header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 50%, var(--color-accent-light) 100%);
    background-size: 300% 300%;
    animation: headerGradient 7s ease infinite;
    color: var(--color-text-light);
    padding: var(--spacing-2xl) var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-2xl);
    box-shadow: 0 6px 20px rgba(30, 144, 255, 0.2);
    text-align: center;
}

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

.header h1 {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header .subtitle {
    font-size: var(--font-size-lg);
    opacity: 0.95;
    font-weight: 300;
}

/* ===========================
   Main Content
   =========================== */
.main {
    flex: 1;
}

/* ===========================
   Settings Panel
   =========================== */
.settings-panel {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
    box-shadow: var(--shadow-sm);
}

.settings-header {
    margin-bottom: var(--spacing-lg);
}

.settings-header h2 {
    font-size: var(--font-size-xl);
    color: #aae4ef;
    margin: 0;
}

.settings-grid {
    display: grid;
    /* Force exactly 3 columns on desktop so we get two neat rows of three inputs */
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

/* Responsive: collapse into auto-fit columns on narrow screens */
@media (max-width: 900px) {
    .settings-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

.setting-item {
    display: flex;
    flex-direction: column;
}

.setting-item label {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-item input {
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.setting-item input:focus {
    outline: none;
    border-color: #00CED1;
    box-shadow: 0 0 0 3px rgba(0, 206, 209, 0.2);
}

input[type="month"] {
    width: 100% !important;
    min-width: 100% !important;
}

input[type="month"]::picker(calendar) {
    width: 100%;
}

/* ===========================
   Month Input Styling
   =========================== */
.month-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    z-index: var(--z-dropdown);
}

/* Position the Litepicker calendar below the monthDisplay input */
.month-input-wrapper .litepicker {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    margin-top: 4px;
    z-index: calc(var(--z-dropdown) + 10);
}

#monthDisplay {
    width: 100%;
    padding-right: 40px;
    cursor: pointer !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-secondary);
}

#monthDisplay:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(170, 228, 239, 0.15);
    border-color: #cfeff4;
}

.calendar-icon {
    position: absolute;
    right: 12px;
    font-size: 1.2rem;
    pointer-events: none;
    color: #aae4ef;
}

/* ===========================
   Litepicker Calendar Styling
   =========================== */

/* Override Litepicker's default colors to match site palette */
.litepicker {
    --litepicker-is-today-color: #f8858a;
    --litepicker-is-today-color-bg: transparent;
    /* Correct variable names for selected day in Litepicker */
    --litepicker-is-start-color: #fff;
    --litepicker-is-start-color-bg: #aae4ef;
    --litepicker-is-end-color: #fff;
    --litepicker-is-end-color-bg: #aae4ef;
    --litepicker-day-color-hover: #aae4ef;
    --litepicker-button-prev-month-color: #aae4ef;
    --litepicker-button-next-month-color: #aae4ef;
    --litepicker-button-prev-month-color-hover: #00CED1;
    --litepicker-button-next-month-color-hover: #00CED1;
}

.litepicker {
    width: 520px !important;
    /* make the calendar bigger */
    min-width: 520px !important;
    max-width: 720px;
    border-radius: var(--radius-lg);
    border: none;
    /* remove the turquoise border */
    font-family: var(--font-family);
}

.litepicker .container {
    width: 100%;
}

.litepicker .month-weekdays {
    background: linear-gradient(135deg, #aae4ef 0%, #00CED1 100%);
    color: white;
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 8px;
}

.litepicker .month-weekdays div {
    padding: 10px 6px;
    font-size: 0.85rem;
    text-align: center;
}

.litepicker .month-header {
    background: linear-gradient(135deg, #aae4ef 0%, #00CED1 100%);
    color: white;
    font-weight: 700;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.litepicker .month-header-label {
    font-size: 1rem;
    font-weight: 700;
}

.litepicker .month-header-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 600;
    font-size: 1rem;
}

.litepicker .month-header-button:hover {
    background: rgba(255, 255, 255, 0.4);
}

.litepicker .days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.litepicker .day {
    padding: 8px 6px;
    font-size: 0.9rem;
    text-align: center;
    height: auto;
    line-height: 1.5;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.litepicker .day:hover:not(.is-disabled):not(.is-other-month) {
    background: #E0F6FF;
    color: #aae4ef;
    font-weight: 600;
    transform: scale(1.05);
}

.litepicker .day.is-today {
    background: transparent;
    color: #f8858a;
    font-weight: 700;
    border: 1px solid #f8858a;
}

/* Selected day: Litepicker uses .is-start-date and .is-end-date (not .is-selected) */
.litepicker .day-item.is-start-date,
.litepicker .day-item.is-end-date {
    background-color: #aae4ef !important;
    color: #fff !important;
    font-weight: 700;
    border-radius: 4px;
}

.litepicker .day.is-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.litepicker .day.is-other-month {
    color: #ddd;
    cursor: default;
}

/* Weekend days use default text color (same as weekdays) */
.litepicker .day.is-weekend {
    color: inherit;
}

/* Selected weekend day keeps white text */
.litepicker .day.is-weekend.is-selected {
    color: #fff !important;
}

/* Today when it's also a weekend: keep red text */
.litepicker .day.is-weekend.is-today {
    color: #f8858a !important;
}

/* ===========================
   Share Section
   =========================== */
.share-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
    box-shadow: var(--shadow-sm);
}

.share-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.share-icon {
    font-size: 1.3rem;
}

.share-header h2 {
    font-size: var(--font-size-xl);
    color: #aae4ef;
    margin: 0;
}

.share-body {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    justify-content: center;
    max-width: 480px;
    margin: 0 auto;
}

.share-url-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    cursor: text;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.share-url-input:focus {
    outline: none;
    border-color: #aae4ef;
    box-shadow: 0 0 0 3px rgba(170, 228, 239, 0.15);
}

.btn-copy {
    padding: 6px 14px;
    background: #aae4ef;
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: #00CED1;
    transform: translateY(-1px);
}

.btn-copy:active {
    transform: translateY(0);
}

.btn-copy.copied {
    background: #32CD32;
}

.copy-confirm {
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: #32CD32;
    min-height: 1.2em;
    text-align: center;
    transition: opacity 0.3s ease;
}

/* ===========================
   Scroll To Top Button
   =========================== */
.scroll-top-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #aae4ef;
    color: #fff;
    border: none;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.2s ease;
    z-index: 999;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    background: #00CED1;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.scroll-top-btn:active {
    transform: translateY(0);
}

/* ===========================
   Time Table Section
   =========================== */
.time-table-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
    box-shadow: var(--shadow-sm);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.table-header h2 {
    font-size: var(--font-size-xl);
    color: #aae4ef;
    margin: 0;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.time-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-secondary);
}

.time-table thead {
    background-color: #aae4ef;
    color: var(--color-text-light);
    font-weight: 600;
}

.time-table th {
    padding: var(--spacing-md);
    text-align: left;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.time-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background-color 0.2s ease;
}

.time-table tbody tr:hover {
    background-color: #E0F6FF;
}

@keyframes row-highlight-fade {
    0% { background-color: rgba(170, 228, 239, 0.5); }
    100% { background-color: transparent; }
}

.time-table tbody tr.highlight-row {
    animation: row-highlight-fade 2.5s ease-out forwards;
}

.time-table td {
    padding: var(--spacing-md);
    font-size: var(--font-size-sm);
}

.time-table input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.time-table input:focus {
    outline: none;
    border-color: #00CED1;
    box-shadow: 0 0 0 2px rgba(0, 206, 209, 0.2);
}

.time-table .day-cell {
    font-weight: 600;
    color: #aae4ef;
    min-width: 60px;
}

.time-table .calculated {
    background-color: #E8EFF5;
    color: #5A6B7A;
    font-weight: 600;
    cursor: not-allowed;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    display: inline-block;
    min-width: 60px;
    text-align: center;
    border: 1px solid #D0DCE8;
}

.time-table .day-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ===========================
   Summary Section
   =========================== */
.summary-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
    box-shadow: var(--shadow-sm);
}

.summary-header {
    margin-bottom: var(--spacing-lg);
}

.summary-header h2 {
    font-size: var(--font-size-xl);
    color: #aae4ef;
    margin: 0;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-2xl);
}

.summary-card {
    background: linear-gradient(135deg, #fff7da 0%, #fff7da 100%);
    border: 2px solid #f2e9b2;
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.summary-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: #d0c57e;
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

.summary-unit {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ===========================
   Salary Section
   =========================== */
.salary-section {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 50%, var(--color-accent-light) 100%);
    background-size: 300% 300%;
    animation: headerGradient 8s ease infinite;
    color: var(--color-text-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.salary-section h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
    font-weight: 600;
}

.salary-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.salary-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    font-size: var(--font-size-base);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: var(--spacing-md);
}

.salary-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.salary-row-total {
    font-weight: 700;
    font-size: var(--font-size-lg);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: none;
    padding-top: var(--spacing-md);
    padding-bottom: 0;
}

.salary-label {
    font-weight: 500;
}

.salary-value {
    font-weight: 700;
    min-width: 100px;
    text-align: right;
    white-space: nowrap;
}

.salary-currency {
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-left: var(--spacing-md);
}

/* ===========================
   Export Section
   =========================== */
.export-section {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-2xl);
}

/* ===========================
   Buttons
   =========================== */
.btn-primary,
.btn-secondary {
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
    text-transform: none;
    letter-spacing: 0.3px;
}

.btn-primary {
    background-color: var(--color-success);
    color: var(--color-text-light);
}

.btn-primary:hover {
    background-color: var(--color-success-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

#exportBtn {
    background-color: #ceecb6;
}

#exportBtn:hover {
    background-color: #b8dda0;
}

#clearMonth {
    background-color: #f8858a;
}

#clearMonth:hover {
    background-color: #f46f76;
}

.btn-secondary {
    background-color: var(--color-accent);
    color: var(--color-text-light);
}

.btn-secondary:hover {
    background-color: var(--color-accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* ===========================
   Footer
   =========================== */
.footer {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

/* ===========================
   Responsive Design (Mobile-First)
   =========================== */

/* Tablet */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }

    .header {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    .header h1 {
        font-size: var(--font-size-2xl);
    }

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

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 480px) {
    :root {
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --font-size-base: 0.95rem;
    }

    .container {
        padding: var(--spacing-sm);
    }

    .header {
        padding: var(--spacing-lg) var(--spacing-md);
        margin-bottom: var(--spacing-lg);
    }

    .header h1 {
        font-size: var(--font-size-2xl);
    }

    .header .subtitle {
        font-size: var(--font-size-base);
    }

    .settings-panel,
    .time-table-section,
    .summary-section {
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-lg);
    }

    .time-table {
        font-size: var(--font-size-sm);
    }

    .time-table th,
    .time-table td {
        padding: var(--spacing-sm);
    }

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

    .salary-section {
        padding: var(--spacing-md);
    }

    .btn-primary,
    .btn-secondary {
        padding: var(--spacing-md) var(--spacing-lg);
        width: 100%;
    }
}

/* ===========================
   Accessibility & Focus Styles
   =========================== */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Motion Preferences */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}