/* Tilitoimisto Suomalainen CRM — Futuristic UI */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --sidebar-width: 260px;
    --bg-primary: #0b0f1a;
    --bg-secondary: #111827;
    --bg-surface: #1f2937;
    --bg-page: #f0f2f7;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --text-primary: #f9fafb;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-dark: #111827;
    --text-muted: #6b7280;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: #e5e7eb;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #6366f1;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-page);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar::-webkit-scrollbar {
    width: 0;
}

.sidebar-brand {
    padding: 1.5rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand small {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar .nav {
    padding: 0.75rem 0.75rem;
    flex: 1;
}

.sidebar .nav-item {
    margin-bottom: 2px;
}

.sidebar .nav-link {
    color: var(--text-secondary);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 450;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    position: relative;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    opacity: 0.7;
    transition: var(--transition);
}

.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar .nav-link:hover i {
    opacity: 1;
}

.sidebar .nav-link.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.sidebar .nav-link.active i {
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-footer .user-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-footer .user-name i {
    font-size: 1rem;
    opacity: 0.6;
}

.sidebar-footer a {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.25rem;
}

.sidebar-footer a:hover {
    color: var(--danger);
}

/* ── Main content ────────────────────────────────────── */

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

/* ── Page header ─────────────────────────────────────── */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-dark);
    letter-spacing: -0.02em;
}

.page-header h1 i {
    color: var(--accent);
    margin-right: 0.25rem;
}

/* ── Cards ───────────────────────────────────────────── */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-header h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-body {
    padding: 1.25rem;
}

/* ── Dashboard stat cards ────────────────────────────── */

.stat-card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

.stat-card .card-body {
    padding: 1.5rem;
}

.stat-card .stat-number {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Stat card accent colors via border-start override */
.stat-card.border-primary::before { background: var(--accent); }
.stat-card.border-danger::before { background: var(--danger); }
.stat-card.border-success::before { background: var(--success); }
.stat-card.border-warning::before { background: var(--warning); }

/* ── Tables ──────────────────────────────────────────── */

.table {
    font-size: 0.85rem;
}

.table th {
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-light);
    padding: 0.85rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: #f3f4f6;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

.table a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.table a:hover {
    color: var(--accent-light);
}

/* ── Badges ──────────────────────────────────────────── */

.badge {
    font-weight: 550;
    font-size: 0.72rem;
    padding: 0.35em 0.75em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.badge-aktiivinen { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-tauolla { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-paattynyt { background: rgba(107, 114, 128, 0.12); color: #4b5563; }
.badge-ei-aloitettu { background: rgba(107, 114, 128, 0.1); color: #6b7280; }
.badge-kesken { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.badge-valmis { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-luonnos { background: rgba(107, 114, 128, 0.12); color: #4b5563; }
.badge-voimassa { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-lahetetty { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.badge-maksettu { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-myohassa { background: rgba(239, 68, 68, 0.12); color: #dc2626; }

/* ── Buttons ─────────────────────────────────────────── */

.btn {
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1rem;
    transition: var(--transition);
    letter-spacing: -0.01em;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* ── Forms ────────────────────────────────────────────── */

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-light);
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group-text {
    border-radius: var(--radius-sm);
    border-color: var(--border-light);
    background: #f9fafb;
    color: var(--text-muted);
}

/* ── Alerts ──────────────────────────────────────────── */

.alert {
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border: none;
    font-weight: 450;
}

/* ── Pagination ──────────────────────────────────────── */

.page-link {
    border-radius: var(--radius-sm);
    margin: 0 2px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
}

/* ── Login page ──────────────────────────────────────── */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, var(--accent-glow) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 50%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
    animation: loginGlow 12s ease-in-out infinite alternate;
}

@keyframes loginGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-5%, 5%) scale(1.1); }
}

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
}

.login-card .card-body {
    padding: 2.5rem;
}

.login-brand {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.03em;
    color: var(--text-dark);
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.login-card .btn-primary {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ── Deadline colors ─────────────────────────────────── */

.deadline-past { color: var(--danger); font-weight: 600; }
.deadline-soon { color: var(--warning); font-weight: 600; }
.deadline-ok { color: var(--success); }

/* ── Matrix view specifics ───────────────────────────── */

.table-bordered th,
.table-bordered td {
    border-color: #f0f0f5;
}

.table-success {
    background-color: rgba(16, 185, 129, 0.06) !important;
}

.table-light {
    background-color: #fafbfc !important;
}

/* ── Quick tools / pikatyökalut ──────────────────────── */

.pikatyokalu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
}

.pikatyokalu-btn:hover {
    transform: translateY(-1px);
}

/* ── Modals ──────────────────────────────────────────── */

.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border-light);
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

/* ── Checkbox styling ────────────────────────────────── */

.form-check-input {
    border-radius: 4px;
    width: 1.1em;
    height: 1.1em;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Empty states ────────────────────────────────────── */

.text-center.py-5 i {
    color: #d1d5db;
}

/* ── Scrollbar (main) ────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ── Print ───────────────────────────────────────────── */

@media print {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 0; }
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
}
