/* Payroll Write Styles - Modals, Forms, Toasts, Overlays */

/* Action buttons in tables and headers */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.action-btn-primary {
    background: #13b5ea;
    color: #fff;
}
.action-btn-primary:hover { background: #0e9cc7; }

.action-btn-success {
    background: #22c55e;
    color: #fff;
}
.action-btn-success:hover { background: #16a34a; }

.action-btn-danger {
    background: #ef4444;
    color: #fff;
}
.action-btn-danger:hover { background: #dc2626; }

.action-btn-outline {
    background: transparent;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.action-btn-outline:hover { background: #f1f5f9; color: #1e293b; }

.action-btn-sm {
    padding: 3px 10px;
    font-size: 11px;
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Header action row */
.header-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

/* Toggle label for inline checkbox toggles */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
    cursor: pointer;
    margin-left: auto;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #13b5ea;
    cursor: pointer;
}

/* Table action column */
.action-cell {
    white-space: nowrap;
}
.action-cell .action-btn + .action-btn {
    margin-left: 4px;
}

/* ===== Modal Overlay ===== */
.pw-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: 10000;
    animation: pw-fadeIn 0.15s ease;
    padding: 20px;
}

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

.pw-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: pw-slideUp 0.2s ease;
}

@keyframes pw-slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.pw-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.pw-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.pw-modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.pw-modal-close:hover { background: #e2e8f0; color: #0f172a; }

.pw-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.pw-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* Large modal for employee forms */
.pw-modal-lg {
    max-width: 800px;
}

/* ===== Form Styles ===== */
.pw-form-section {
    margin-bottom: 20px;
}

.pw-form-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.pw-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.pw-form-group {
    display: flex;
    flex-direction: column;
}

.pw-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.pw-form-group label .required {
    color: #ef4444;
}

.pw-form-group input,
.pw-form-group select,
.pw-form-group textarea {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s;
    font-family: inherit;
}

.pw-form-group input:focus,
.pw-form-group select:focus,
.pw-form-group textarea:focus {
    outline: none;
    border-color: #13b5ea;
    box-shadow: 0 0 0 3px rgba(19, 181, 234, 0.1);
}

.pw-form-group input.error,
.pw-form-group select.error {
    border-color: #ef4444;
}

.pw-form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.pw-form-group .hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

/* Inline checkbox */
.pw-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.pw-checkbox-row input[type="checkbox"] { width: 16px; height: 16px; }
.pw-checkbox-row label { font-size: 13px; color: #475569; margin-bottom: 0; }

/* Repeatable section (bank accounts, earnings lines) */
.pw-repeatable-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    position: relative;
}

.pw-repeatable-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    background: #fee2e2;
    border-radius: 4px;
    cursor: pointer;
    color: #ef4444;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pw-repeatable-remove:hover { background: #fecaca; }

.pw-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px dashed #cbd5e1;
    background: transparent;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}
.pw-add-btn:hover { border-color: #13b5ea; color: #13b5ea; }

/* ===== Confirm Overlay ===== */
.pw-confirm-body {
    text-align: center;
    padding: 10px 0;
}

.pw-confirm-body p {
    font-size: 14px;
    color: #475569;
    margin-bottom: 12px;
    line-height: 1.6;
}

.pw-confirm-body .pw-warning {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #92400e;
    font-weight: 600;
    font-size: 13px;
}

.pw-confirm-body .pw-danger-warning {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #991b1b;
    font-weight: 600;
    font-size: 13px;
}

.pw-typed-confirm-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    font-family: monospace;
    margin-top: 8px;
}
.pw-typed-confirm-input:focus {
    outline: none;
    border-color: #ef4444;
}

/* Summary grid in confirms */
.pw-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
    text-align: left;
}

.pw-summary-item {
    background: #f8fafc;
    border-radius: 6px;
    padding: 8px 12px;
}

.pw-summary-item .pw-summary-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
}

.pw-summary-item .pw-summary-value {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

/* ===== Toast Notifications ===== */
.pw-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pw-toast {
    background: #fff;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    min-width: 280px;
    max-width: 400px;
    animation: pw-toastIn 0.3s ease;
    border-left: 4px solid;
}

@keyframes pw-toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.pw-toast-success { border-left-color: #22c55e; color: #16a34a; }
.pw-toast-error { border-left-color: #ef4444; color: #dc2626; }
.pw-toast-info { border-left-color: #3b82f6; color: #2563eb; }

.pw-toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.pw-toast-message {
    flex: 1;
}

/* ===== Loading spinner for buttons ===== */
.pw-btn-loading {
    position: relative;
    pointer-events: none;
}
.pw-btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    transform: translate(-50%, -50%);
}

/* Processing overlay for irreversible actions */
.pw-processing {
    text-align: center;
    padding: 30px;
}

.pw-processing-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #13b5ea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.pw-processing p {
    font-size: 15px;
    color: #475569;
    font-weight: 500;
}

/* Timesheet hours grid */
.pw-hours-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.pw-hours-grid label {
    text-align: center;
    font-size: 11px;
}

.pw-hours-grid input {
    text-align: center;
    padding: 6px 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .pw-modal { max-width: 100%; margin: 10px; }
    .pw-form-row { grid-template-columns: 1fr; }
    .pw-summary-grid { grid-template-columns: 1fr; }
    .pw-hours-grid { grid-template-columns: repeat(4, 1fr); }
    .header-action-row { flex-wrap: wrap; }
}

/* ===== Dark Mode ===== */
[data-theme="dark"] .toggle-label {
    color: #94a3b8;
}

[data-theme="dark"] .action-btn-outline {
    color: #94a3b8;
    border-color: #475569;
}
[data-theme="dark"] .action-btn-outline:hover {
    background: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .pw-overlay { background: rgba(0, 0, 0, 0.7); }

[data-theme="dark"] .pw-modal {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .pw-modal-header { border-bottom-color: #334155; }
[data-theme="dark"] .pw-modal-title { color: #f1f5f9; }
[data-theme="dark"] .pw-modal-close { background: #334155; color: #94a3b8; }
[data-theme="dark"] .pw-modal-close:hover { background: #475569; color: #f1f5f9; }
[data-theme="dark"] .pw-modal-footer { border-top-color: #334155; }

[data-theme="dark"] .pw-form-section-title { color: #94a3b8; border-bottom-color: #334155; }

[data-theme="dark"] .pw-form-group label { color: #94a3b8; }
[data-theme="dark"] .pw-form-group input,
[data-theme="dark"] .pw-form-group select,
[data-theme="dark"] .pw-form-group textarea {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
[data-theme="dark"] .pw-form-group input:focus,
[data-theme="dark"] .pw-form-group select:focus,
[data-theme="dark"] .pw-form-group textarea:focus {
    border-color: #13b5ea;
    box-shadow: 0 0 0 3px rgba(19, 181, 234, 0.2);
}
[data-theme="dark"] .pw-form-group .hint { color: #64748b; }

[data-theme="dark"] .pw-checkbox-row label { color: #94a3b8; }

[data-theme="dark"] .pw-repeatable-item {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .pw-repeatable-remove { background: #450a0a; color: #f87171; }
[data-theme="dark"] .pw-repeatable-remove:hover { background: #7f1d1d; }

[data-theme="dark"] .pw-add-btn { border-color: #475569; color: #94a3b8; }
[data-theme="dark"] .pw-add-btn:hover { border-color: #13b5ea; color: #13b5ea; }

[data-theme="dark"] .pw-confirm-body p { color: #94a3b8; }
[data-theme="dark"] .pw-confirm-body .pw-warning { background: #422006; border-color: #713f12; color: #fbbf24; }
[data-theme="dark"] .pw-confirm-body .pw-danger-warning { background: #450a0a; border-color: #7f1d1d; color: #f87171; }
[data-theme="dark"] .pw-typed-confirm-input { background: #0f172a; border-color: #475569; color: #e2e8f0; }

[data-theme="dark"] .pw-summary-item { background: #0f172a; }
[data-theme="dark"] .pw-summary-item .pw-summary-label { color: #64748b; }
[data-theme="dark"] .pw-summary-item .pw-summary-value { color: #f1f5f9; }

[data-theme="dark"] .pw-toast {
    background: #1e293b;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .pw-toast-success { color: #4ade80; }
[data-theme="dark"] .pw-toast-error { color: #f87171; }
[data-theme="dark"] .pw-toast-info { color: #60a5fa; }

[data-theme="dark"] .pw-processing p { color: #94a3b8; }
[data-theme="dark"] .pw-processing-spinner { border-color: #334155; border-top-color: #13b5ea; }
