@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ==========================================================================
   CSS Variables & Theming
   ========================================================================== */
:root {
    /* Light Theme (Woodcraft Palette) */
    --bg-color: #faf8f5;
    --surface-color: #ffffff;
    --primary-color: #8b5a2b; /* Oak Brown */
    --primary-hover: #a06935;
    --text-main: #2c241b;
    --text-muted: #73675a;
    --border-color: #e6e0d8;
    --shadow-sm: 0 1px 3px rgba(139, 90, 43, 0.05);
    --shadow-md: 0 4px 6px rgba(139, 90, 43, 0.08);
    --shadow-lg: 0 10px 25px rgba(139, 90, 43, 0.12);
    
    /* Functional Colors */
    --success: #3b82f6; /* Blueish to contrast with wood? Or green: #10b981 */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Metrics & Spacing */
    --font-family: 'Outfit', sans-serif;
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-full: 9999px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 72px;
    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-color: #1a1714;
    --surface-color: #26211c;
    --primary-color: #d4a373; /* Light Birch */
    --primary-hover: #e6b88a;
    --text-main: #f5f0eb;
    --text-muted: #a69b91;
    --border-color: #3b332b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    -webkit-font-smoothing: antialiased;
}

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

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

ul {
    list-style: none;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

img, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-main);
    margin-bottom: 0.5em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-muted); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

/* ==========================================================================
   UI Components
   ========================================================================== */
/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition-fast);
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
}
[data-theme="dark"] .btn-primary {
    color: #1a1714;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: #fff;
}
[data-theme="dark"] .btn-outline:hover {
    color: #1a1714;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.1);
}

[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(212, 163, 115, 0.15);
}

/* Cards */
.card {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Layouts
   ========================================================================== */

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-inline-end: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal);
    z-index: 100;
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

.sidebar-logo svg {
    color: var(--primary-color);
    width: 32px;
    height: 32px;
}

.sidebar.collapsed .sidebar-logo span {
    display: none;
}

.sidebar-nav {
    padding: 1.5rem 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    border-left: 3px solid transparent; /* default indication */
}

/* RTL adjustment for hover boarder */
[dir="rtl"] .nav-item {
    border-left: none;
    border-right: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(139, 90, 43, 0.05); /* very light primary */
    color: var(--primary-color);
}

[data-theme="dark"] .nav-item:hover, [data-theme="dark"] .nav-item.active {
    background-color: rgba(212, 163, 115, 0.1);
}

.nav-item.active {
    border-left-color: var(--primary-color);
}
[dir="rtl"] .nav-item.active {
    border-right-color: var(--primary-color);
}

.nav-item svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}

/* Main Content */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: var(--header-height);
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
    background-color: rgba(139, 90, 43, 0.05);
    color: var(--primary-color);
}

[data-theme="dark"] .icon-btn:hover {
    background-color: rgba(212, 163, 115, 0.1);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0; /* Changed dynamically based on RTL */
    margin-top: 0.5rem;
    min-width: 150px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: 1000;
}

[dir="rtl"] .dropdown-menu {
    right: auto;
    left: 0;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    color: var(--text-main);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
    width: 100%;
    text-align: start;
}

.dropdown-item:hover {
    background-color: rgba(139, 90, 43, 0.05);
    color: var(--primary-color);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: rgba(212, 163, 115, 0.1);
}


.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* ==========================================================================
   Responsive & RTL adjustments
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
    }
    
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

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