/* =============================================
   Üretim Takip Sistemi - Custom Styles
   Premium dark-accented modern design
   ============================================= */

:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Color Palette */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Backgrounds */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1b4b;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: rgba(99, 102, 241, 0.3);
    --bg-topbar: #ffffff;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: rgba(255, 255, 255, 0.7);
    --text-sidebar-active: #ffffff;

    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* ---- Dark Theme Variables ---- */
[data-bs-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-topbar: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --primary-light: rgba(99, 102, 241, 0.2);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ---- Global ---- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    background-image: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: var(--accent);
}

.sidebar-logo {
    max-height: 40px;
    max-width: 160px;
    width: auto;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-logo {
    max-height: 28px;
    width: auto;
    object-fit: contain;
}

.sidebar-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0;
    transition: var(--transition);
    margin: 2px 8px;
    border-radius: var(--radius-sm);
}

.sidebar-nav .nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.sidebar-nav .nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 12px 20px;
}

.nav-label {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-logout {
    color: rgba(255, 255, 255, 0.4);
    border: none;
    padding: 6px;
    transition: var(--transition);
}

.btn-logout:hover {
    color: var(--danger);
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.topbar-actions {
    margin-left: auto;
    font-size: 0.85rem;
}

.sidebar-toggle {
    color: var(--text-primary);
    font-size: 1.3rem;
    padding: 4px;
}

.content-wrapper {
    padding: 24px;
}

/* ---- Sidebar Overlay (Mobile) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Cards ---- */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.stat-card .stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-card .stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-card .stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-card .stat-icon.accent {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent);
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Card Block ---- */
.card-block {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-block .card-block-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-block .card-block-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.card-block .card-block-body {
    padding: 24px;
}

/* ---- Tables ---- */
.table-custom {
    margin: 0;
}

.table-custom thead th {
    background: var(--bg-body);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 16px;
    white-space: nowrap;
}

.table-custom tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table-custom tbody tr:hover {
    background: var(--primary-light);
}

/* ---- Buttons ---- */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 10px 20px;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-action {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 0.85rem;
}

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

.btn-action.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ---- Forms ---- */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* ---- Progress Bars ---- */
.progress {
    height: 10px;
    border-radius: 99px;
    background: #f1f5f9;
}

.progress-bar {
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.6s ease;
}

.progress-bar.over-target {
    background: linear-gradient(90deg, var(--success), #34d399);
}

/* ---- Badge ---- */
.badge-role {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-role.admin {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.badge-role.personel {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent);
}

/* ---- Login Page ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand .icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.login-logo {
    max-height: 120px;
    max-width: 280px;
    width: auto;
    margin: 0 auto 20px;
    display: block;
    object-fit: contain;
}

.login-brand h2 {
    font-weight: 800;
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.login-brand p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---- Install Page ---- */
.install-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
    padding: 20px;
}

.install-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

/* ---- Repeat Last Entry Button ---- */
.btn-repeat {
    background: linear-gradient(135deg, var(--accent), #0891b2);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-repeat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    color: #fff;
}

/* ---- Chart Container ---- */
.chart-container {
    position: relative;
    height: 280px;
}

/* ---- Filter Bar ---- */
.filter-bar {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--border-color);
}

.empty-state h5 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 16px;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    /* Mobile Logout Fix */
    .sidebar-footer {
        padding-bottom: env(safe-area-inset-bottom, 50px) !important;
        margin-bottom: 15px;
        background: var(--bg-sidebar);
        /* Ensure footer stays above content */
    }
}

@media (max-width: 575.98px) {
    .topbar {
        padding: 0 16px;
    }

    .page-title {
        font-size: 1rem;
    }

    .login-card,
    .install-card {
        padding: 28px 24px;
    }

    .table-custom thead th,
    .table-custom tbody td {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.4s ease forwards;
}

.fade-in-up:nth-child(1) {
    animation-delay: 0.05s;
}

.fade-in-up:nth-child(2) {
    animation-delay: 0.1s;
}

.fade-in-up:nth-child(3) {
    animation-delay: 0.15s;
}

.fade-in-up:nth-child(4) {
    animation-delay: 0.2s;
}

/* ---- Scrollbar ---- */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 99px;
}

/* ---- Target Progress Card ---- */
.target-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.target-item .target-name {
    min-width: 120px;
    font-weight: 600;
    font-size: 0.9rem;
}

.target-item .target-progress {
    flex: 1;
}

.target-item .target-values {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: right;
}

/* ---- Print Styles ---- */
@media print {

    .sidebar,
    .topbar,
    .sidebar-overlay,
    .btn,
    .filter-bar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-wrapper {
        padding: 0 !important;
    }
}