/* =============================================
   Kintai Mate - メインスタイルシート
   ============================================= */

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --primary-bg: #eef2ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --sidebar-width: 240px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ===== Login ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-md);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-top: 12px;
}

.app-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.25rem;
}

.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

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

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

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

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

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

.btn-full { width: 100%; }

.login-staff-link {
    text-align: center;
    margin-top: 20px;
}

.login-staff-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.login-staff-link a:hover {
    text-decoration: underline;
}

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--gray-100);
}

.app-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}

.nav-menu {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-menu li {
    margin-bottom: 4px;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-menu li a:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

.nav-menu li.active a {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

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

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
}

.logout-link {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
}

.logout-link:hover {
    color: var(--gray-800);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
    max-width: 1100px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
}

/* ===== Card ===== */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

/* ===== Staff Form ===== */
.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.flex-1 { flex: 1; }

.form-action {
    padding-bottom: 0;
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-100);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.95rem;
}

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

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-edit:hover { background: var(--primary-bg); }
.btn-delete:hover { background: var(--danger-bg); }

/* ===== Clock Page ===== */
.clock-display {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 30px;
}

.clock-display::after {
    content: '🕐';
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    opacity: 0.3;
}

.clock-time {
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 4px;
    font-variant-numeric: tabular-nums;
}

.clock-date {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 4px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

.staff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.staff-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    border: 2px solid transparent;
}

.staff-card:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.staff-card-avatar {
    font-size: 2.5rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.staff-card-name {
    font-weight: 600;
    color: var(--gray-700);
}

/* Clock Panel */
.staff-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.staff-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.label-small {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.staff-display-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--gray-800);
}

.btn-back {
    margin-left: auto;
    background: none;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--gray-500);
    transition: all 0.2s;
}

.btn-back:hover {
    border-color: var(--gray-400);
    color: var(--gray-700);
}

.clock-buttons {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.clock-btn {
    flex: 1;
    padding: 30px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

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

.clock-btn-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
}

.clock-in { background: var(--primary); }
.clock-in:hover { background: var(--primary-dark); }
.clock-out { background: var(--danger); }
.clock-out:hover { background: #dc2626; }
.break-start { background: var(--warning); }
.break-start:hover { background: #d97706; }
.break-end { background: var(--success); }
.break-end:hover { background: #15803d; }

.done-message {
    text-align: center;
    padding: 30px;
    font-size: 1.1rem;
    color: var(--gray-500);
    background: var(--gray-50);
    border-radius: var(--radius);
}

.status-bar {
    display: flex;
    justify-content: space-between;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
}

.status-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.status-time {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

/* ===== Summary Page ===== */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: white;
    border-radius: var(--radius);
    padding: 16px 30px;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}

.month-arrow {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.month-arrow:hover {
    background: var(--primary-bg);
}

.month-display {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gray-800);
    min-width: 160px;
    text-align: center;
}

.period-display {
    text-align: center;
    font-size: 0.8rem;
    color: var(--gray-400);
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

.settings-row {
    display: flex;
    justify-content: center;
    gap: 30px;
    background: white;
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item label {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

.setting-item select {
    padding: 6px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
}

.setting-item select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--gray-200);
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--gray-700); }

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

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

/* Total Pay Card */
.total-pay-card {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: var(--radius);
    padding: 24px 30px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-pay-label {
    font-size: 1rem;
    font-weight: 600;
}

.total-pay-sub {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 4px;
}

.total-pay-amount {
    font-size: 2.5rem;
    font-weight: 700;
}

/* Detail Stats */
.detail-header {
    margin-bottom: 0;
}

.detail-stats {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.stat-box {
    flex: 1;
    background: white;
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.stat-green { color: var(--success); }

.stat-dark {
    background: var(--gray-800);
    color: white;
}

.stat-dark .stat-label { color: var(--gray-400); }
.stat-dark .stat-value { color: white; }

/* Staff Select */
.staff-select {
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: white;
    min-width: 200px;
}

.staff-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Deductions */
.deduction-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.deduction-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid var(--gray-100);
}

.deduction-total {
    font-size: 1rem;
    color: var(--gray-700);
}

.deduction-total strong {
    font-size: 1.1rem;
    color: var(--primary);
}

/* ===== Settings Page ===== */
.settings-info {
    padding: 8px 0;
}

.settings-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.settings-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    min-width: 100px;
}

.settings-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.settings-form {
    max-width: 400px;
}

.msg-box {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.msg-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.msg-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== Export Buttons ===== */
.export-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn-export {
    flex: 1;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid;
}

.btn-csv {
    background: white;
    color: #16a34a;
    border-color: #16a34a;
}

.btn-csv:hover {
    background: #f0fdf4;
}

.btn-pdf {
    background: white;
    color: #dc2626;
    border-color: #dc2626;
}

.btn-pdf:hover {
    background: #fef2f2;
}

/* ===== Editable Time Cells ===== */
.editable-time {
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.editable-time:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

/* ===== 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: 1000;
}

.modal-card {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.modal-date {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-bottom: 20px;
}

.modal-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-form input[type="time"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.modal-form input[type="time"]:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 100%;
        height: auto;
        bottom: 0;
        top: auto;
        left: 0;
        border-right: none;
        border-top: 1px solid var(--gray-200);
        z-index: 100;
    }

    .sidebar-header,
    .sidebar-footer { display: none; }

    .nav-menu {
        display: flex;
        justify-content: space-around;
        padding: 8px;
    }

    .nav-menu li { margin: 0; }

    .nav-menu li a {
        flex-direction: column;
        gap: 4px;
        padding: 8px 16px;
        font-size: 0.75rem;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-bottom: 80px;
    }

    .clock-time { font-size: 2.5rem; }
    .clock-display::after { display: none; }

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

    .clock-buttons { flex-direction: column; }

    .detail-stats { flex-wrap: wrap; }
    .stat-box { min-width: calc(50% - 8px); }

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

    .total-pay-card {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .settings-row { flex-direction: column; gap: 12px; }

    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 8px; }
}
