/* =========================================================================
   Terra Tech - Modern Green & White Theme
   ========================================================================= */

:root {
    /* Color Palette */
    --tt-primary: #10b981;
    /* Vibrant Emerald Green */
    --tt-primary-dark: #059669;
    /* Darker Green for hovers */
    --tt-primary-light: #d1fae5;
    /* Very Light Green for backgrounds */
    --tt-secondary: #6ee7b7;
    /* Soft Green */

    --tt-bg-light: #f3f4f6;
    /* Main Body Background (Off-white/Gray) */
    --tt-surface: #ffffff;
    /* Cards & Sidebar Background */

    --tt-text-main: #1f2937;
    /* Dark Gray for primary text */
    --tt-text-muted: #6b7280;
    /* Medium Gray for secondary text */

    --tt-border: #e5e7eb;
    /* Light Gray borders */

    /* Shadows & Radii */
    --tt-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --tt-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --tt-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --tt-radius-md: 0.5rem;
    --tt-radius-lg: 0.75rem;
    --tt-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Sidebar Enhanced */
    --tt-sidebar-width: 270px;
    --tt-sidebar-collapsed-width: 80px;
    --tt-sidebar-bg: linear-gradient(160deg, #022c22 0%, #064e3b 40%, #065f46 100%);
    --tt-sidebar-glass: rgba(255, 255, 255, 0.07);
    --tt-overlay-bg: rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--tt-bg-light);
    color: var(--tt-text-main);
}

/* =========================================
   Typography & Utilities
   ========================================= */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--tt-text-main);
    font-weight: 700;
}

.text-primary {
    color: var(--tt-primary) !important;
}

/* =========================================
   Sidebar Styling — Dark Glassmorphism
   ========================================= */

/* Trigger zone */
.sidebar-trigger {
    position: fixed;
    top: 0;
    right: 0;
    width: 32px;
    height: 100px;
    z-index: 999;
    cursor: pointer;
    transition: background 0.3s ease;
}
.sidebar-trigger:hover {
    background: rgba(16, 185, 129, 0.15);
    border-right: 3px solid var(--tt-primary);
}

/* Main sidebar panel */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--tt-sidebar-width);
    background: linear-gradient(160deg, #021a14 0%, #042e21 45%, #054030 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
    padding-top: 1rem;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(16,185,129,0.3) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(16,185,129,0.3); border-radius: 4px; }

.sidebar.collapsed {
    transform: translateX(100%);
}

/* Brand */
.sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem 1rem;
    text-decoration: none;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .sidebar-brand .sb-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #fbbf24);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(16,185,129,0.4);
    animation: sbPulse 3s ease-in-out infinite;
}
@keyframes sbPulse {
    0%,100% { box-shadow: 0 4px 14px rgba(16,185,129,0.4); }
    50%      { box-shadow: 0 6px 22px rgba(16,185,129,0.7); }
}
.sidebar .sidebar-brand .sb-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.sidebar .sidebar-brand .sb-text span:first-child {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
}
.sidebar .sidebar-brand .sb-text span:last-child {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sidebar.collapsed .sidebar-brand .sb-text { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }

/* Section label */
.sidebar-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.25);
    padding: 0.75rem 1.4rem 0.25rem;
    display: block;
}
.sidebar.collapsed .sidebar-section-label { display: none; }

/* Nav links */
.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.84rem;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    margin: 0.1rem 0.75rem;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    text-decoration: none;
    position: relative;
    white-space: nowrap;
    gap: 0.75rem;
}
.sidebar .nav-link .sb-nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.6);
    flex-shrink: 0;
    transition: all 0.25s ease;
}
.sidebar .nav-link:hover {
    background: rgba(16,185,129,0.12);
    color: #fff;
    transform: translateX(-3px);
}
.sidebar .nav-link:hover .sb-nav-icon {
    background: rgba(16,185,129,0.25);
    color: #34d399;
    box-shadow: 0 0 12px rgba(16,185,129,0.3);
}
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.7rem 0;
    margin: 0.1rem 0.5rem;
    gap: 0;
}
.sidebar.collapsed .nav-link span:not(.sb-nav-icon),
.sidebar.collapsed .nav-link::after,
.sidebar.collapsed .collapse-arrow { display: none; }
.sidebar.collapsed .nav-link:hover { transform: scale(1.08); }

/* Active state */
.sidebar .nav-link.active {
    background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(16,185,129,0.1));
    color: #34d399;
    border: 1px solid rgba(16,185,129,0.25);
}
.sidebar .nav-link.active .sb-nav-icon {
    background: rgba(16,185,129,0.3);
    color: #6ee7b7;
    box-shadow: 0 0 16px rgba(16,185,129,0.4);
}

.sidebar-heading { display: none; }

/* Collapse inner */
.sidebar .collapse-inner {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    margin: 0.15rem 0.75rem 0.3rem;
    padding: 0.35rem 0;
    border: 1px solid rgba(255,255,255,0.05);
}
.sidebar.collapsed .collapse { display: none !important; }

.sidebar .collapse-inner .collapse-item {
    padding: 0.38rem 1rem 0.38rem 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 0.78rem;
    transition: all 0.2s ease;
    border-radius: 7px;
    margin: 0.05rem 0.4rem;
}
.sidebar .collapse-inner .collapse-item::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(16,185,129,0.4);
    flex-shrink: 0;
    margin-left: -0.8rem;
    transition: all 0.2s ease;
}
.sidebar .collapse-inner .collapse-item:hover,
.sidebar .collapse-inner .collapse-item.active {
    color: #6ee7b7;
    background: rgba(16,185,129,0.1);
    transform: translateX(-3px);
}
.sidebar .collapse-inner .collapse-item:hover::before,
.sidebar .collapse-inner .collapse-item.active::before {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16,185,129,0.6);
}

/* Divider */
.sidebar-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin: 0.5rem 0.8rem !important;
    opacity: 1 !important;
}

/* Arrow toggle */
.collapse-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 7px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.07);
    margin-right: auto;
    margin-left: 0;
    flex-shrink: 0;
    color: rgba(255,255,255,0.4);
}
.collapse-arrow:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255,255,255,0.8);
}
.collapse-arrow[aria-expanded="true"] {
    transform: rotate(-90deg);
    background: rgba(16,185,129,0.2);
    color: #34d399;
}
.sidebar .nav-link::after,
.sidebar .nav-link[data-bs-toggle="collapse"]::after {
    display: none !important;
    content: none !important;
}

/* Sidebar logout button */
.sidebar-logout {
    margin: 0.5rem 0.75rem;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 10px;
    color: rgba(252,165,165,0.85);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
    cursor: pointer;
}
.sidebar-logout:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.4);
    color: #fca5a5;
    transform: translateX(-3px);
}
.sidebar-logout .sb-nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239,68,68,0.15);
    color: #f87171;
    flex-shrink: 0;
}

/* User info pill at bottom */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin: 0.5rem 0.75rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}
.sidebar-user .su-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg,#10b981,#059669);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}
.sidebar-user .su-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    overflow: hidden;
}
.sidebar-user .su-info .su-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user .su-info .su-role {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.sidebar.collapsed .sidebar-user { display: none; }

/* Main wrapper */
.main-wrapper {
    margin-right: 0;
    transition: margin-right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}
.main-wrapper.pushed  { margin-right: var(--tt-sidebar-width); }
.main-wrapper.expanded { margin-right: 0; width: 100%; }

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        z-index: 1000;
        box-shadow: none;
    }
    .sidebar.show-mobile {
        transform: translateX(0);
        box-shadow: -5px 0 20px rgba(0,0,0,0.5);
    }
    .main-wrapper { margin-right: 0 !important; width: 100% !important; }
    .sidebar-trigger { display: none; }
    .navbar { padding: 0.75rem 1rem; }
    .navbar-brand { font-size: 1rem; }
}

/* Touch Target Optimization */
.nav-link, .btn, .collapse-item {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* Table Responsiveness Fix */
.table-responsive {
    border-radius: var(--tt-radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


/* =========================================
   Topbar / Navbar
   ========================================= */
.navbar {
    background-color: var(--tt-surface) !important;
    box-shadow: var(--tt-shadow-sm);
    padding: 1rem 1.5rem;
    border-bottom: none !important;
}

/* =========================================
   Cards Components
   ========================================= */
.card {
    background-color: var(--tt-surface);
    border: none !important;
    border-radius: var(--tt-radius-lg) !important;
    box-shadow: var(--tt-shadow-md) !important;
    margin-bottom: 1.5rem;
    transition: var(--tt-transition);
}

.card:hover {
    box-shadow: var(--tt-shadow-lg) !important;
}

.card-header {
    background-color: transparent !important;
    border-bottom: 1px solid var(--tt-border) !important;
    padding: 1.25rem 1.5rem;
    font-weight: 700;
}

.card-header-custom {
    background-color: var(--tt-primary) !important;
    color: white !important;
    border-radius: var(--tt-radius-lg) var(--tt-radius-lg) 0 0 !important;
}

/* Adjust Dashboard Top Border Highlights */
.border-primary {
    border-color: var(--tt-primary) !important;
}

.border-success {
    border-color: var(--tt-secondary) !important;
}

.border-info {
    border-color: #3b82f6 !important;
    /* Keep blue for variety if needed, or change */
}

.border-warning {
    border-color: #f59e0b !important;
}

.border-danger {
    border-color: #ef4444 !important;
}

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


/* =========================================
   Buttons & Inputs
   ========================================= */
.btn {
    border-radius: var(--tt-radius-md);
    padding: 0.5rem 1rem;
    font-weight: 600;
    transition: var(--tt-transition);
}

.btn-primary {
    background-color: var(--tt-primary) !important;
    border-color: var(--tt-primary) !important;
    color: white !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--tt-primary-dark) !important;
    border-color: var(--tt-primary-dark) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.25);
}

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

.btn-light:hover {
    background-color: #e5e7eb;
}

.form-control,
.form-select {
    border-radius: var(--tt-radius-md);
    border: 1px solid var(--tt-border);
    padding: 0.6rem 1rem;
    transition: var(--tt-transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tt-primary);
    box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.25);
}

/* =========================================
   Standardized Page Headers
   ========================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header h1 {
    margin-bottom: 0;
    font-size: 1.75rem;
}

.page-header .btn {
    padding: 0.6rem 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    width: auto;
}

/* Back Button Standard */
.btn-back {
    background-color: var(--tt-surface);
    border: 1px solid var(--tt-border);
    color: var(--tt-text-muted);
    padding: 0.5rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    text-decoration: none;
    transition: var(--tt-transition);
}

.btn-back:hover {
    background-color: var(--tt-bg-light);
    color: var(--tt-primary-dark);
    border-color: var(--tt-primary);
    transform: translateX(5px); /* RTL slide back effect */
}

.btn-back i {
    transition: transform 0.3s ease;
}

.btn-back:hover i {
    transform: translateX(3px);
}


/* =========================================
   Tables
   ========================================= */
.table {
    margin-bottom: 0;
    color: var(--tt-text-main);
}

.table th {
    border-bottom: 2px solid var(--tt-border);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--tt-text-muted);
}

.table td {
    vertical-align: middle;
    border-bottom: 1px solid var(--tt-border);
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
    background-color: rgba(243, 244, 246, 0.5);
    /* Very light gray */
}

/* Overriding bootstrap dark table header to green theme */
.table-dark {
    background-color: var(--tt-primary-light);
    color: var(--tt-primary-dark);
}

.table-dark th {
    color: var(--tt-primary-dark);
    border-bottom-color: var(--tt-primary);
}

/* =========================================
   Animations & Hover Utilities
   ========================================= */
.hover-zoom:hover {
    transform: translateY(-5px);
}

/* =========================================
   Standardized Table Actions
   ========================================= */
.actions-column {
    white-space: nowrap;
    width: 1%;
    text-align: center;
}

.actions-wrapper {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    align-items: center;
}

/* Ensure small buttons in tables are compact and consistent */
.table .btn-sm {
    min-height: 32px !important;
    height: 32px !important;
    padding: 0 0.75rem !important;
    font-size: 0.8rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    white-space: nowrap;
}

.table .btn-sm i {
    margin-left: 5px; /* RTL Gap for icon */
    font-size: 0.85rem;
}
/* =========================================
   Excel Export Button
   ========================================= */
.export-excel-btn {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%) !important;
    border: none !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 6px rgba(40, 167, 69, 0.2) !important;
    transition: all 0.3s ease !important;
    margin-bottom: 20px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    font-family: inherit !important;
}

.export-excel-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.3) !important;
}

.export-excel-btn i {
    margin-left: 8px !important; /* RTL Gap for icon */
    font-size: 1.1rem;
}


/* =========================================
   Custom Brand Logo (Fiberglass Rebars)
   ========================================= */
.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    text-decoration: none !important;
    transition: var(--tt-transition);
}

.brand-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #10b981 0%, #fbbf24 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    transition: all 0.4s ease;
}

.brand-logo:hover .logo-icon {
    transform: rotate(10deg) scale(1.1);
    box-shadow: 0 6px 15px rgba(251, 191, 36, 0.4);
}

.brand-logo .logo-text {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.brand-logo .logo-text .main-title {
    font-size: 1.2rem;
    color: #ffffff;
    text-transform: uppercase;
}

/* Specific adjustment for Topbar (Light Background) */
.navbar .brand-logo .logo-text .main-title {
    color: var(--tt-text-main) !important;
}

.brand-logo .logo-text .sub-title {
    font-size: 0.65rem;
    color: #fbbf24;
    text-transform: uppercase;
    margin-top: 4px;
    font-weight: 600;
}
