/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f0f4f0;
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100%;
    padding-bottom: 72px;
}

/* ===== Header ===== */
header {
    background-color: #1b5e20;
    color: white;
    padding: 14px 16px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* ===== Main ===== */
main {
    max-width: 600px;
    margin: 0 auto;
    padding: 12px;
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    border-top: 1px solid #ddd;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 6px;
    border: none;
    background: none;
    color: #888;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
    min-height: 52px;
    gap: 2px;
}

.nav-btn.active {
    color: #1b5e20;
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.nav-label {
    line-height: 1;
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Section Card ===== */
.section-card {
    background: white;
    border-radius: 12px;
    padding: 20px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

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

/* ===== Typography ===== */
h2 {
    font-size: 1.15rem;
    color: #1b5e20;
    margin-bottom: 14px;
}

h3 {
    font-size: 1.05rem;
    color: #1b5e20;
    margin-bottom: 10px;
}

.help-text {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background-color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #1b5e20;
    box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.12);
}

textarea {
    resize: vertical;
    min-height: 70px;
}

.input-centered {
    text-align: center;
    max-width: 280px;
    margin: 0 auto;
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background-color: #1b5e20;
    color: white;
    width: 100%;
    padding: 14px;
}

.btn-large {
    font-size: 1.05rem;
    padding: 16px;
    border-radius: 12px;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-approve {
    background-color: #2e7d32;
    color: white;
    padding: 10px 18px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-reject {
    background-color: #c62828;
    color: white;
    padding: 10px 18px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-cancel-leave {
    background-color: #fff;
    color: #c62828;
    border: 1.5px solid #e57373;
    padding: 8px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-small {
    padding: 7px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-outline {
    background-color: white;
    color: #1b5e20;
    border: 1.5px solid #1b5e20;
}

.btn-danger-outline {
    background-color: white;
    color: #c62828;
    border: 1.5px solid #e57373;
}

/* ===== Messages & Toast ===== */
.message {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    text-align: center;
}

.message.success {
    background-color: #e8f5e9;
    color: #1b5e20;
    border: 1px solid #a5d6a7;
}

.message.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.3s ease;
    max-width: 90%;
    text-align: center;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Leave Balance Preview (Apply tab) ===== */
.balance-preview {
    background: #e8f5e9;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.balance-preview[hidden] {
    display: none;
}

.balance-label {
    color: #555;
}

.balance-count {
    font-weight: 700;
    color: #1b5e20;
    font-size: 1.1rem;
}

.balance-unit {
    color: #555;
}

/* ===== Date Info Bar ===== */
.date-info {
    background: #fff8e1;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.83rem;
    color: #6d5600;
    line-height: 1.5;
}

.date-info .days-count {
    font-weight: 700;
    color: #e65100;
}

.date-info .holiday-note {
    display: block;
    margin-top: 4px;
    color: #c62828;
    font-size: 0.8rem;
}

.date-info .conflict-warn {
    display: block;
    margin-top: 4px;
    color: #c62828;
    font-weight: 600;
    font-size: 0.82rem;
}

/* ===== Balance Cards (My Leaves) ===== */
.balance-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.balance-card {
    border-radius: 10px;
    padding: 12px 6px;
    text-align: center;
}

.balance-number {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
}

.balance-text {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.balance-total { background: #e3f2fd; color: #1565c0; }
.balance-total .balance-number { color: #1565c0; }
.balance-used { background: #fff3e0; color: #e65100; }
.balance-used .balance-number { color: #e65100; }
.balance-remaining { background: #e8f5e9; color: #2e7d32; }
.balance-remaining .balance-number { color: #2e7d32; }
.balance-pending-count { background: #fff8e1; color: #f57f17; }
.balance-pending-count .balance-number { color: #f57f17; }

/* ===== My Leaves Header & Filter ===== */
.my-leaves-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.my-leaves-header h2 {
    margin-bottom: 0;
}

.my-filter-row {
    margin-bottom: 12px;
}

.my-filter-row select {
    width: 100%;
}

/* ===== Filters ===== */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.filters select {
    flex: 1;
}

/* ===== Request Cards ===== */
.requests-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.request-card {
    background-color: white;
    border-radius: 12px;
    padding: 14px;
    border-left: 4px solid #ccc;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.request-card.pending { border-left-color: #f9a825; }
.request-card.approved { border-left-color: #2e7d32; }
.request-card.rejected { border-left-color: #c62828; }
.request-card.cancelled { border-left-color: #888; }

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

.request-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1b5e20;
}

.request-status {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.status-pending { background-color: #fff8e1; color: #f57f17; }
.status-approved { background-color: #e8f5e9; color: #2e7d32; }
.status-rejected { background-color: #ffebee; color: #c62828; }
.status-cancelled { background-color: #f5f5f5; color: #888; }

.request-meta {
    font-size: 0.82rem;
    color: #777;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.request-meta-tag {
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
}

.request-dates {
    font-size: 0.85rem;
    color: #444;
    margin-bottom: 4px;
    font-weight: 500;
}

.request-days {
    font-size: 0.78rem;
    color: #888;
    margin-bottom: 6px;
}

.request-reason {
    font-size: 0.83rem;
    color: #555;
    margin-bottom: 6px;
    font-style: italic;
    padding: 8px 10px;
    background: #fafafa;
    border-radius: 6px;
}

.request-rejection {
    font-size: 0.82rem;
    color: #c62828;
    padding: 8px 10px;
    background: #fff5f5;
    border-radius: 6px;
    margin-bottom: 6px;
}

.request-rejection strong {
    display: block;
    font-size: 0.78rem;
    margin-bottom: 2px;
}

/* ===== Manager Insights ===== */
.manager-insights {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insight-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.insight-label {
    font-weight: 600;
    color: #555;
    font-size: 0.75rem;
}

.insight-value {
    color: #333;
}

.insight-holiday {
    background: #fff8e1;
    border-radius: 6px;
    padding: 6px 8px;
    margin: 2px -4px;
}

.insight-holiday .insight-label {
    color: #e65100;
}

.insight-holiday .insight-value {
    color: #bf360c;
}

.insight-warning {
    background: #ffebee;
    border-radius: 6px;
    padding: 6px 8px;
    margin: 2px -4px;
}

.insight-warning .insight-label {
    color: #c62828;
}

.insight-warning .insight-value {
    color: #b71c1c;
}

.insight-ok {
    color: #2e7d32;
}

.insight-ok .insight-value {
    color: #2e7d32;
}

.btn-edit-balance {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
}

.request-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.request-actions .btn {
    flex: 1;
}

/* ===== Manager ===== */
.lock-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.manager-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.manager-top-bar h2 {
    margin-bottom: 0;
}

.manager-top-actions {
    display: flex;
    gap: 8px;
}

/* ===== Stats Row ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-card {
    border-radius: 10px;
    padding: 12px 6px;
    text-align: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.stat-pending { background: #fff8e1; }
.stat-pending .stat-number { color: #f57f17; }
.stat-pending .stat-label { color: #f57f17; }
.stat-approved { background: #e8f5e9; }
.stat-approved .stat-number { color: #2e7d32; }
.stat-approved .stat-label { color: #2e7d32; }
.stat-rejected { background: #ffebee; }
.stat-rejected .stat-number { color: #c62828; }
.stat-rejected .stat-label { color: #c62828; }
.stat-total { background: #e3f2fd; }
.stat-total .stat-number { color: #1565c0; }
.stat-total .stat-label { color: #1565c0; }

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #1b5e20;
    margin-bottom: 14px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: white;
    color: #1b5e20;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.toggle-btn.active {
    background: #1b5e20;
    color: white;
}

/* ===== Calendar ===== */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.calendar-month-label {
    font-weight: 700;
    font-size: 1rem;
    color: #1b5e20;
}

.calendar-filter {
    margin-bottom: 10px;
}

.calendar-filter select {
    width: 100%;
}

.calendar-grid {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 10px;
}

.calendar-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #1b5e20;
}

.cal-day-name {
    text-align: center;
    padding: 8px 2px;
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
}

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

.cal-day {
    min-height: 48px;
    padding: 4px;
    border: 0.5px solid #eee;
    position: relative;
    cursor: pointer;
    transition: background 0.15s;
}

.cal-day:active {
    background: #f0f4f0;
}

.cal-day.empty {
    background: #fafafa;
    cursor: default;
}

.cal-day.today {
    background: #e8f5e9;
}

.cal-day.holiday {
    background: #fff3e0;
}

.cal-day-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: #333;
}

.cal-day.empty .cal-day-number {
    color: #ccc;
}

.cal-day.holiday .cal-day-number {
    color: #e65100;
}

.cal-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 2px;
}

.cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.cal-dot.dot-approved { background: #2e7d32; }
.cal-dot.dot-pending { background: #f9a825; }

.calendar-legend {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 0.78rem;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-approved { background: #2e7d32; }
.dot-pending { background: #f9a825; }
.dot-holiday { background: #e65100; }

.calendar-day-detail {
    background: white;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.calendar-day-detail h4 {
    font-size: 0.9rem;
    color: #1b5e20;
    margin-bottom: 8px;
}

.detail-item {
    font-size: 0.83rem;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-item:last-child {
    border-bottom: none;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 14px 0;
}

.pagination-info {
    font-size: 0.82rem;
    color: #666;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 24px 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.modal-text {
    font-size: 0.88rem;
    color: #666;
    margin-bottom: 16px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.modal-actions .btn {
    flex: 1;
}

/* ===== Loading & Empty ===== */
.loading {
    text-align: center;
    color: #888;
    padding: 32px 16px;
    font-size: 0.9rem;
}

.loading::before {
    content: '';
    display: block;
    width: 28px;
    height: 28px;
    border: 3px solid #ddd;
    border-top-color: #1b5e20;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 16px;
    font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    header {
        padding: 10px 12px;
    }

    header h1 {
        font-size: 1.05rem;
    }

    main {
        padding: 10px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .filters {
        flex-direction: column;
        gap: 8px;
    }

    .stats-row {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .stat-number {
        font-size: 1.3rem;
    }

    .balance-cards {
        gap: 6px;
    }

    .balance-number {
        font-size: 1.2rem;
    }

    .request-header {
        flex-direction: row;
        align-items: center;
    }

    .request-actions {
        flex-direction: row;
    }

    .cal-day {
        min-height: 42px;
    }

    .section-card {
        padding: 16px 14px;
    }
}

@media (min-width: 769px) {
    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
        border: 1px solid #ddd;
        border-bottom: none;
    }
}
