/* IranSans Font Faces */
@font-face {
    font-family: 'IranSans';
    src: url('itansans_l.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IranSans';
    src: url('iransans.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IranSans';
    src: url('iransans_m.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --primary: #6366f1;
    /* Indigo */
    --primary-dark: #4f46e5;
    --navy-dark: #1e293b;

    --text-main: #334155;
    --text-muted: #94a3b8;
    --text-light: #f8fafc;

    --border: #e2e8f0;
    --radius: 20px;

    /* Sidebar Variables */
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #64748b;
    --sidebar-text-active: #4f46e5;
    --sidebar-bg-active: #eef2ff;
    --sidebar-border: #f1f5f9;

    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'IranSans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
    direction: rtl;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    position: relative;
    transition: margin-right 0.3s ease, width 0.3s ease;
}

/* --- Hero Background --- */
.hero-background {
    background-color: var(--navy-dark);
    height: 280px;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

/* --- Mobile Toggle Button --- */
.sidebar-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    display: none;
    /* Hidden on desktop */
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    color: var(--text-main);
    transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #f8fafc;
    transform: scale(1.05);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* --- Sidebar (Modern Pastel Design) --- */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.02);
}

/* Sidebar Header */
.sidebar-header {
    padding: 32px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.25);
}

.brand-logo i {
    width: 24px;
    height: 24px;
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--navy-dark);
    letter-spacing: -0.5px;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    padding: 0 24px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
}

.menu-category {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 24px 12px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    margin-bottom: 6px;
    border: 1px solid transparent;
}

.nav-link:hover {
    background: #f8fafc;
    color: var(--navy-dark);
}

.nav-link.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    border-color: rgba(99, 102, 241, 0.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.05);
}

.nav-link i {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.dropdown-arrow {
    margin-right: auto;
    width: 16px !important;
    height: 16px !important;
    transition: transform 0.2s;
}

.nav-item-has-submenu.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Submenu */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-right: 20px;
}

.submenu.open {
    max-height: 300px;
}

.submenu .nav-link {
    font-size: 0.9rem;
    padding: 10px 16px;
    color: #64748b;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.submenu .nav-link:hover {
    color: var(--primary);
    transform: translateX(-4px);
}

.submenu .nav-link.active {
    color: var(--primary);
    font-weight: 700;
}

.submenu .nav-link::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    margin-left: 12px;
    transition: background 0.2s;
}

.submenu .nav-link.active::before {
    background: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--sidebar-border);
    background: white;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid #f1f5f9;
    transition: all 0.2s;
}

.user-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.user-avatar {
    width: 44px;
    height: 44px;
    background: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--navy-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

.logout-icon {
    color: #ef4444;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-icon:hover {
    background: #fee2e2;
    transform: rotate(90deg);
}

/* --- Header --- */
.app-header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1000;
    color: white;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 800;
    opacity: 0.95;
}

.header-profile {
    position: relative;
    cursor: pointer;
    z-index: 10001;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 6px 6px 16px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: background 0.2s;
}

.profile-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
}

.profile-info {
    text-align: left;
}

.profile-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.profile-role {
    font-size: 0.75rem;
    opacity: 0.8;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    background: white;
    color: var(--navy-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-float);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    color: var(--text-main);
    z-index: 99999;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

.dropdown-item.danger {
    color: #ef4444;
}

.dropdown-item.danger:hover {
    background: #fef2f2;
}

/* --- Content Wrapper --- */
.content-wrapper {
    padding: 0 40px 40px;
    position: relative;
    z-index: 1;
    margin-top: 40px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    border: none;
    position: relative;
    overflow: hidden;
}

.metric-card {
    padding: 28px;
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-4px);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.metric-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.metric-icon.purple {
    background: #f3e8ff;
    color: #7c3aed;
}

.metric-icon.blue {
    background: #eff6ff;
    color: #2563eb;
}

.metric-icon.green {
    background: #ecfdf5;
    color: #10b981;
}

.metric-icon.orange {
    background: #fff7ed;
    color: #f97316;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
    margin-bottom: 6px;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 10px;
}

.trend-up {
    background: #dcfce7;
    color: #166534;
}

.trend-down {
    background: #fee2e2;
    color: #991b1b;
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
    position: relative;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

th {
    text-align: right;
    padding: 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

td {
    padding: 16px;
    background: white;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    font-size: 0.95rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* --- Badges & Buttons --- */
.status-badge {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-success {
    background: #dcfce7;
    color: #166534;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-danger {
    background: #fee2e2;
    color: #991b1b;
}

.status-info {
    background: #e0f2fe;
    color: #075985;
}

.btn {
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    font-family: inherit;
    transition: all 0.2s;
}

.input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* --- Utilities --- */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.badge.neutral {
    background: #f1f5f9;
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* --- Invoice Details Page --- */
.invoice-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 24px;
}

.invoice-main {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-card);
}

.invoice-sidebar {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    height: fit-content;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.invoice-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.invoice-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.amount {
    font-family: 'IranSans', monospace;
    font-weight: 700;
}

.invoice-info-box {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    font-size: 1rem;
}

.invoice-total-final {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    background: #eff6ff;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
}

/* Timeline */
.timeline {
    position: relative;
    padding-right: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 9px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: 4px;
    top: 6px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px var(--border);
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

.timeline-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Sticky Header Styles */
.sticky-header th {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #f1f5f9 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Compact Table Styles */
.compact-table th,
.compact-table td {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Price Cell Style */
.price-cell {
    background-color: #f0fdf4;
    color: #15803d;
    font-weight: 700;
}

/* --- Responsive Behavior --- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    .sidebar-toggle-btn {
        display: flex;
    }

    .app-header {
        padding-right: 70px;
    }

    .content-wrapper {
        padding: 0 20px 40px;
    }
}

/* Print Styles */
@media print {

    .sidebar,
    .app-header,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    .content-wrapper {
        padding: 0;
        margin-top: 0;
    }

    .card {
        box-shadow: none;
        padding: 0;
        border: none;
    }

    .table-container {
        overflow: visible !important;
        max-height: none !important;
    }

    .sticky-header th {
        position: static;
        box-shadow: none;
    }

    .print-hidden {
        display: none !important;
    }

    body {
        background: white;
    }

    .invoice-container {
        display: block;
    }

    .invoice-sidebar {
        display: none;
    }

    .invoice-main {
        box-shadow: none;
        padding: 0;
    }

    table {
        border: 1px solid #ddd;
    }

    th,
    td {
        border: 1px solid #ddd;
        padding: 8px;
    }
}