/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 80px;
}

/* Header */
.app-header {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.app-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 env(safe-area-inset-bottom, 8px);
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
    border-radius: var(--radius-sm);
}

.nav-btn.active {
    color: var(--primary);
}

.nav-btn:hover {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.4rem;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 16px;
}

.tab-content {
    display: none;
}

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

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text);
}

.card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text);
}

/* Today Card */
.today-card {
    border-left: 4px solid var(--primary);
}

.today-status {
    padding: 12px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.status-text {
    color: var(--primary-dark);
    font-weight: 500;
    text-align: center;
}

/* Check Info */
.check-info {
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

/* Overtime Result */
.overtime-result {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #a7f3d0;
}

.overtime-result h3 {
    color: #065f46;
    margin-bottom: 12px;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.result-label {
    display: block;
    font-size: 0.8rem;
    color: #065f46;
    margin-bottom: 4px;
}

.result-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: #047857;
}

.result-money {
    color: #b45309;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Holiday Toggle */
.holiday-toggle {
    margin-top: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px;
    background: #fef3c7;
    border-radius: var(--radius-sm);
    border: 1px solid #fcd34d;
}

.toggle-text {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Summary Card */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.summary-item {
    text-align: center;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.summary-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Settings */
.settings-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-of-type {
    border-bottom: none;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-with-prefix {
    display: flex;
    align-items: center;
}

.input-prefix {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--text-light);
    font-weight: 600;
}

.input-with-prefix .input {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.select-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: white;
}

/* Days Grid */
.days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.day-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.day-checkbox:has(input:checked) {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.day-checkbox input {
    cursor: pointer;
}

/* Salary Info */
.salary-info {
    margin-top: 12px;
    padding: 12px;
    background: #f0fdf4;
    border-radius: var(--radius-sm);
    border: 1px solid #bbf7d0;
}

.salary-info p {
    font-size: 0.85rem;
    color: #166534;
    margin-bottom: 4px;
}

.salary-info p:last-child {
    margin-bottom: 0;
}

/* Sync Buttons */
.sync-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

/* Danger Zone */
.danger-zone {
    border: 1px solid #fecaca;
    background: #fef2f2;
}

/* History */
.history-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.history-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-totals {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.total-item {
    font-size: 0.9rem;
}

.total-item strong {
    color: var(--primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.history-entry.holiday {
    border-left-color: var(--warning);
    background: #fffbeb;
}

.entry-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.entry-details {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}

.entry-hours {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.entry-amount {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
}

.entry-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

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

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-style: italic;
}

/* Cuts */
.cut-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--success);
}

.cut-item h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.cut-item p {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
    }
    
    .main-content {
        padding: 12px;
    }
}

/* Install Banner */
.install-banner {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.install-banner p {
    font-size: 0.9rem;
}

.install-banner .btn {
    background: white;
    color: var(--primary);
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content.active {
    animation: fadeIn 0.2s ease;
}


/* ============ Auth Screen ============ */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.auth-error {
    margin-top: 12px;
    padding: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #dc2626;
    font-size: 0.85rem;
    text-align: center;
}

.auth-success {
    margin-top: 12px;
    padding: 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    color: #166534;
    font-size: 0.85rem;
    text-align: center;
}

/* ============ Header Right ============ */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-email {
    font-size: 0.7rem;
    opacity: 0.8;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: white;
}

/* ============ Loading Overlay ============ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 12px;
}

.loading-overlay p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============ Sync Status ============ */
.sync-status-card {
    text-align: center;
}

.sync-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.sync-dot.online {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


/* ============ Modal ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    z-index: 5001;
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

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

.modal-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    min-height: 40px;
}

.modal-preview-content p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.preview-total {
    margin-top: 8px;
    font-size: 1rem !important;
    color: var(--primary) !important;
}

/* ============ Entry Actions & Badge ============ */
.entry-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.entry-edit, .entry-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.entry-edit:hover, .entry-delete:hover {
    opacity: 1;
}

.entry-type-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.history-entry.holiday .entry-type-badge {
    background: #fef3c7;
    color: #92400e;
}

/* ============ OT Type Selector ============ */
.ot-type-selector {
    margin-top: 8px;
    padding: 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.ot-type-selector label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.ot-type-selector .select-input {
    flex: 1;
}

/* ============ Breakdown ============ */
.result-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #a7f3d0;
}

.breakdown-line {
    font-size: 0.8rem;
    color: #065f46;
    margin-bottom: 4px;
}


/* ============ Password Field & Remember Me ============ */
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field .input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    font-size: 1.1rem;
    padding: 6px;
    color: var(--text-light);
}

.password-toggle:hover {
    color: var(--text);
}

.remember-me {
    margin-top: 12px;
    margin-bottom: 4px;
}

.remember-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-light);
}

.remember-label input {
    cursor: pointer;
    width: 16px;
    height: 16px;
}


/* ============ Period & Filter Labels ============ */
.filter-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    text-align: center;
}

.period-pay-info {
    font-size: 0.8rem;
    color: var(--success);
    text-align: center;
    margin-bottom: 12px;
    font-weight: 500;
}
