/* ==========================================================================
   ISO 9001 Multi-Tenant Form Yönetim Sistemi - Core Design System (CSS)
   Aydınlık (Light) & Karanlık (Dark) Tema Destekli Ultra-Modern Tasarım
   ========================================================================== */

:root {
    /* Color Palette - Light Mode */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-subtle: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-color: #e2e8f0;
    --border-subtle: #cbd5e1;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

    --accent-cyan: #0284c7;
    --accent-emerald: #059669;
    --accent-amber: #d97706;
    --accent-rose: #e11d48;

    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-hover: #1e293b;
    --sidebar-active: #312e81;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px 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 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.35);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --header-height: 68px;
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    /* Color Palette - Dark Mode */
    --bg-main: #090d16;
    --bg-card: #131926;
    --bg-card-subtle: #1c2438;
    --bg-glass: rgba(19, 25, 38, 0.85);
    --border-color: #232d42;
    --border-subtle: #334155;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    --sidebar-bg: #0b0f19;
    --sidebar-hover: #172033;
    --sidebar-active: #4338ca;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.45);
}

/* Base & Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout Wrapper */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand-text {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 11px;
    color: #818cf8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    list-style: none;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 12px 6px;
}

.sidebar-menu-item {
    margin-bottom: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.sidebar-link.active {
    background: var(--primary-gradient);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.sidebar-badge {
    margin-left: auto;
    background-color: var(--accent-rose);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-y: auto;
}

/* Navbar */
.app-navbar {
    height: var(--header-height);
    background-color: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Action Icon Buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

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

.btn-icon .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background-color: var(--accent-rose);
    border-radius: 50%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.2;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-card-subtle);
    border-color: var(--border-subtle);
}

.btn-success {
    background-color: var(--accent-emerald);
    color: #ffffff;
}

.btn-danger {
    background-color: var(--accent-rose);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Content Body */
.app-content {
    padding: 28px;
    flex: 1;
}

/* Metric Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
}

.stat-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* Card */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

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

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.custom-table th {
    background-color: var(--bg-card-subtle);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.custom-table tr:hover td {
    background-color: var(--bg-card-subtle);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background-color: rgba(5, 150, 105, 0.15); color: #10b981; }
.badge-warning { background-color: rgba(217, 119, 6, 0.15); color: #f59e0b; }
.badge-danger { background-color: rgba(225, 29, 72, 0.15); color: #f43f5e; }
.badge-primary { background-color: rgba(79, 70, 229, 0.15); color: #6366f1; }
.badge-info { background-color: rgba(2, 132, 199, 0.15); color: #0ea5e9; }

/* Form Controls */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

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

/* Modal Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

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

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastSlideIn 0.3s ease;
}

.toast.success { border-left-color: var(--accent-emerald); }
.toast.error { border-left-color: var(--accent-rose); }
.toast.warning { border-left-color: var(--accent-amber); }

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

/* Responsive Mobile Rules */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: -280px;
        transition: left 0.3s ease;
    }
    .app-sidebar.mobile-open {
        left: 0;
    }
    .app-navbar {
        padding: 0 16px;
    }
    .app-content {
        padding: 16px;
    }
}
