/* =============================================
   CRC CRM - Custom Styles
   Colors: #8B1A1A (Primary), #C0392B (Accent)
   ============================================= */

:root {
    --crc-primary: #8B1A1A;
    --crc-primary-dark: #6B1515;
    --crc-primary-light: #A52525;
    --crc-secondary: #FFFFFF;
    --crc-accent: #C0392B;
    --crc-dark: #1A1A2E;
    --crc-dark-sidebar: #1E1E2D;
    --crc-light: #F5F6FA;
    --crc-success: #27AE60;
    --crc-warning: #F39C12;
    --crc-danger: #E74C3C;
    --crc-info: #3498DB;
    --sidebar-width: 260px;
}

/* Body */
body {
    background-color: var(--crc-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

#wrapper {
    min-height: 100vh;
    display: flex;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    height: 100vh;
    background: var(--crc-dark-sidebar) !important;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-inner {
    min-height: 100%;
    padding-bottom: 2rem;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

.sidebar-header {
    background: rgba(139, 26, 26, 0.3);
    position: sticky;
    top: 0;
    z-index: 10;
}

.crc-logo-icon {
    width: 50px;
    height: 50px;
    background: var(--crc-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 0.6rem 1.2rem;
    margin: 2px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    white-space: nowrap;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--crc-primary);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar .nav-item small {
    display: block;
    padding: 0.5rem 1.2rem 0.2rem;
}

/* ========== Page Content ========== */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    flex: 1;
    width: calc(100% - var(--sidebar-width));
}

#page-content-wrapper.expanded {
    margin-left: 0;
    width: 100%;
}

.container-fluid {
    flex: 1;
}

/* ========== Navbar ========== */
.navbar {
    z-index: 999;
}

/* ========== Stat Cards ========== */
.stat-card {
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* ========== Buttons ========== */
.btn-crc {
    background-color: var(--crc-primary);
    border-color: var(--crc-primary);
    color: #fff;
}

.btn-crc:hover {
    background-color: var(--crc-primary-dark);
    border-color: var(--crc-primary-dark);
    color: #fff;
}

.btn-crc:focus {
    box-shadow: 0 0 0 0.2rem rgba(139, 26, 26, 0.25);
}

.btn-crc-primary {
    background-color: var(--crc-primary) !important;
    border-color: var(--crc-primary) !important;
    color: #fff !important;
}

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

.btn-outline-crc:hover {
    background-color: var(--crc-primary);
    color: #fff;
}

/* ========== Text Colors ========== */
.text-crc {
    color: var(--crc-primary) !important;
}

.bg-crc-primary {
    background-color: var(--crc-primary) !important;
}

/* ========== Cards ========== */
.card {
    border-radius: 12px;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
}

/* ========== Tables ========== */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
}

/* ========== Badges ========== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.7em;
}

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

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
}

.crc-logo-large {
    width: 80px;
    height: 80px;
    background: var(--crc-primary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 2px;
}

.login-card .form-control {
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

.login-card .input-group-text {
    border-radius: 8px 0 0 8px;
}

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

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== Animation ========== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== Language Toggle ========== */
.lang-toggle {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.lang-toggle:hover {
    background: rgba(0,0,0,0.05);
}

/* =============================================
   RTL Support
   ============================================= */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
}

[dir="rtl"] #page-content-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-width);
    transition: margin-right 0.3s ease;
}

[dir="rtl"] #page-content-wrapper.expanded {
    margin-right: 0;
}

[dir="rtl"] .sidebar .nav-link {
    text-align: right;
}

[dir="rtl"] .sidebar .nav-link i {
    margin-right: 0;
    margin-left: 0.5rem;
}

[dir="rtl"] .stat-icon {
    margin-right: 0 !important;
    margin-left: 1rem !important;
}

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

[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

[dir="rtl"] .me-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }

[dir="rtl"] .ps-1 { padding-left: 0 !important; padding-right: 0.25rem !important; }
[dir="rtl"] .ps-2 { padding-left: 0 !important; padding-right: 0.5rem !important; }
[dir="rtl"] .ps-3 { padding-left: 0 !important; padding-right: 1rem !important; }
[dir="rtl"] .ps-4 { padding-left: 0 !important; padding-right: 1.5rem !important; }
[dir="rtl"] .pe-1 { padding-right: 0 !important; padding-left: 0.25rem !important; }
[dir="rtl"] .pe-2 { padding-right: 0 !important; padding-left: 0.5rem !important; }
[dir="rtl"] .pe-3 { padding-right: 0 !important; padding-left: 1rem !important; }
[dir="rtl"] .pe-4 { padding-right: 0 !important; padding-left: 1.5rem !important; }

[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }

[dir="rtl"] .dropdown-toggle::after {
    margin-left: 0;
    margin-right: 0.255em;
}

[dir="rtl"] .table-responsive {
    direction: rtl;
}

[dir="rtl"] .border-start {
    border-left: 0 !important;
    border-right: var(--bs-border-width) var(--bs-border-style) !important;
}

[dir="rtl"] .border-end {
    border-right: 0 !important;
    border-left: var(--bs-border-width) var(--bs-border-style) !important;
}

[dir="rtl"] .rounded-start {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: var(--bs-border-radius) !important;
    border-bottom-right-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .rounded-end {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: var(--bs-border-radius) !important;
    border-bottom-left-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .list-unstyled {
    padding-right: 0;
    padding-left: unset;
}

[dir="rtl"] .list-unstyled li {
    padding-right: 0;
    padding-left: unset;
}

/* RTL Form inputs */
[dir="rtl"] .form-control {
    text-align: right;
}

[dir="rtl"] .input-group-text {
    text-align: right;
}

[dir="rtl"] .form-check-input {
    margin-left: 0;
    margin-right: -1.25em;
}

/* RTL Sidebar scrollbar position */
[dir="rtl"] .sidebar::-webkit-scrollbar {
    left: 4px;
    right: auto;
}

/* RTL Notification badge position fix */
[dir="rtl"] .translate-middle {
    transform: translate(-50%, -50%) !important;
}

/* RTL Navbar items alignment */
[dir="rtl"] .navbar .d-flex {
    flex-direction: row-reverse;
}

/* RTL Dropdown menus should open to the left */
[dir="rtl"] .dropdown-menu-end[data-bs-popper] {
    left: 0;
    right: auto;
}

/* RTL Fix for position utilities */
[dir="rtl"] .start-100 {
    left: auto;
    right: 100% !important;
}

/* RTL Fix for translate middle badge */
[dir="rtl"] .translate-middle {
    transform: translate(-50%, -50%) !important;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

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

    #page-content-wrapper {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    #page-content-wrapper.expanded {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Print Styles */
@media print {
    .sidebar, .navbar, .btn, .footer, #toggle-sidebar {
        display: none !important;
    }
    #page-content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
    body {
        background: white !important;
    }
}

[dir="rtl"] @media print {
    #page-content-wrapper {
        margin-right: 0 !important;
    }
}
