/* ============================================
   Quotation System - Modern ERP Dashboard
   Custom Stylesheet
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --dark: #1e293b;
    --light: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --text: #334155;
    --text-muted: #94a3b8;
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* ============================================
   Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    font-size: 0.975rem;
    line-height: 1.5;
    color: var(--text);
    background-color: #f1f5f9;
    overflow-x: hidden;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

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

.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 24px;
    margin-top: var(--topbar-height);
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar-header {
    min-height: 100px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: relative;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
}

.sidebar-logo img {
    max-height: 65px;
    max-width: 150px;
    object-fit: contain;
}

.sidebar-logo i {
    font-size: 1.6rem;
    color: #60a5fa;
}

.sidebar-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-section {
    font-size: 0.65rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 20px 24px 8px;
}

.sidebar .nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 400;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar .nav-item .nav-link:hover {
    color: var(--white);
    background: rgba(255,255,255,0.05);
}

.sidebar .nav-item.active .nav-link {
    color: var(--white);
    background: rgba(37, 99, 235, 0.15);
    border-left-color: #60a5fa;
    font-weight: 500;
}

.sidebar .nav-item .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center;
}

/* ============================================
   Topbar
   ============================================ */
.topbar {
    height: var(--topbar-height);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1030;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

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

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--light);
    color: var(--primary);
}

.page-title h5 {
    font-weight: 600;
    color: var(--dark);
    font-size: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.financial-year-badge {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.topbar-user:hover {
    background: var(--light);
    color: var(--text);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 0.85rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-name { font-size: 0.82rem; font-weight: 600; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* Dashboard Stat Cards */
.stat-card {
    border: none;
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-top: 12px;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.stat-card.bg-blue { background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.stat-card.bg-blue .stat-icon { background: #2563eb; color: var(--white); }

.stat-card.bg-green { background: linear-gradient(135deg, #ecfdf5, #d1fae5); }
.stat-card.bg-green .stat-icon { background: #059669; color: var(--white); }

.stat-card.bg-orange { background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.stat-card.bg-orange .stat-icon { background: #d97706; color: var(--white); }

.stat-card.bg-purple { background: linear-gradient(135deg, #faf5ff, #e9d5ff); }
.stat-card.bg-purple .stat-icon { background: #7c3aed; color: var(--white); }

.stat-card.bg-red { background: linear-gradient(135deg, #fef2f2, #fecaca); }
.stat-card.bg-red .stat-icon { background: #dc2626; color: var(--white); }

.stat-card.bg-teal { background: linear-gradient(135deg, #f0fdfa, #ccfbf1); }
.stat-card.bg-teal .stat-icon { background: #0d9488; color: var(--white); }

/* ============================================
   Tables
   ============================================ */
.table-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 20px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.table-header h6 {
    font-weight: 600;
    color: var(--dark);
    margin: 0;
}

table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
}

table.dataTable thead th {
    background: #f8fafc;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    padding: 12px 14px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table.dataTable tbody td {
    padding: 10px 14px;
    font-size: 0.82rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

table.dataTable tbody tr:hover {
    background: #f8fafc;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    font-size: 0.82rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-sm {
    font-size: 0.75rem;
    padding: 5px 10px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

/* Action Dropdown */
.action-dropdown .dropdown-toggle {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
}

.action-dropdown .dropdown-toggle::after { display: none; }

.action-dropdown .dropdown-menu {
    min-width: 160px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
}

.action-dropdown .dropdown-item {
    font-size: 0.8rem;
    padding: 7px 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-dropdown .dropdown-item:hover {
    background: #f1f5f9;
}

.action-dropdown .dropdown-item i { width: 16px; text-align: center; }

/* ============================================
   Forms
   ============================================ */
.form-control, .form-select {
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

/* ============================================
   Modals
   ============================================ */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px 20px;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-body { padding: 20px; }

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 14px 20px;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    font-weight: 500;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

/* ============================================
   DataTables Overrides
   ============================================ */
div.dataTables_wrapper div.dataTables_length select {
    min-width: 60px;
}

div.dataTables_wrapper div.dataTables_filter input {
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 0.82rem;
}

.dt-buttons .btn {
    font-size: 0.75rem;
    padding: 5px 12px;
}

/* ============================================
   Select2 Overrides
   ============================================ */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--border) !important;
    border-radius: 6px !important;
    font-size: 0.85rem !important;
    min-height: 38px !important;
}

/* ============================================
   Login Page (Modern Centered Card)
   ============================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
    top: -200px;
    left: -150px;
    z-index: 0;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.03) 0%, transparent 70%);
    bottom: -200px;
    right: -150px;
    z-index: 0;
}

.login-card {
    background: #ffffff;
    border: none;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo img {
    max-height: 130px;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 8px;
}

.login-logo i {
    font-size: 2.8rem;
    color: #2563eb;
    margin-bottom: 10px;
    display: block;
}

.login-logo h4 {
    color: #1e293b;
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.login-logo p {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0;
}

.login-card .form-label {
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.login-card .input-group-text {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-right: none;
    color: #94a3b8;
    border-radius: 8px 0 0 8px;
    padding-left: 14px;
}

.login-card .form-control {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-left: none;
    color: #1e293b !important;
    padding: 12px 14px;
    font-size: 0.9rem;
    border-radius: 0 8px 8px 0;
    transition: var(--transition);
}

.login-card .form-control:hover {
    background: #ffffff;
    color: #1e293b !important;
    border-color: #94a3b8;
}

.login-card .form-control:-webkit-autofill,
.login-card .form-control:-webkit-autofill:hover, 
.login-card .form-control:-webkit-autofill:focus,
.login-card .form-control:-webkit-autofill:active {
    -webkit-text-fill-color: #1e293b !important;
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

.login-card .form-control::placeholder {
    color: #94a3b8;
}

.login-card .form-control:focus {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: none;
    color: #1e293b;
}

.login-card .form-control:focus + .input-group-text,
.login-card .input-group:focus-within .input-group-text,
.login-card .input-group:focus-within .toggle-password {
    border-color: #2563eb;
    color: #2563eb;
    background: #ffffff;
}

.login-card .input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    border-radius: 8px;
}

.login-card .form-control:not(:last-child) {
    border-radius: 0;
    border-right: none;
}

.login-card .toggle-password {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-left: none;
    color: #94a3b8;
    border-radius: 0 8px 8px 0;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.login-card .toggle-password:hover {
    color: #475569;
    background: #f8fafc;
}

.forgot-password-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.forgot-password-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.login-card .btn-primary {
    background: #2563eb;
    border: none;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    width: 100%;
    justify-content: center;
    box-shadow: none;
    transition: all 0.2s ease;
    color: #ffffff;
}

.login-card .btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.login-card .login-error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.login-footer {
    position: relative;
    z-index: 1;
    margin-top: 20px;
}

.login-footer p {
    color: #94a3b8 !important;
}


/* ============================================
   Responsive
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .content-wrapper {
        margin-left: 0 !important;
    }
    .topbar {
        left: 0 !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 16px;
    }
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

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

.fade-in { animation: fadeIn 0.3s ease forwards; }

/* Prevent Flash of Unstyled Content (FOUC) on DataTables */
.dataTable-pre-init {
    opacity: 0 !important;
}
.dataTable-initialized {
    opacity: 1 !important;
    transition: opacity 0.15s ease-in-out;
}


/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Page Breadcrumb */
.page-breadcrumb {
    font-size: 0.78rem;
    margin-bottom: 20px;
}

.page-breadcrumb a { color: var(--text-muted); }
.page-breadcrumb a:hover { color: var(--primary); }

/* Toastr overrides */
#toast-container > div {
    border-radius: 8px !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: 'Poppins', sans-serif !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 16px;
}

.empty-state h5 {
    font-weight: 600;
    color: #475569;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Print Styles */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .content-wrapper { margin-left: 0 !important; }
    .main-content { padding: 0 !important; margin-top: 0 !important; }
}

/* Premium overrides for DataTables export buttons */
.dt-buttons.btn-group {
    gap: 5px;
}
div.dt-buttons {
    float: none;
    display: inline-flex;
    gap: 8px;
    margin-bottom: 0px;
}
div.dt-buttons button.dt-button, 
div.dt-buttons a.dt-button,
.dt-buttons .btn {
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    box-shadow: none !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
}
div.dt-buttons button.dt-button:hover,
div.dt-buttons a.dt-button:hover,
.dt-buttons .btn:hover {
    background: var(--light) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    transform: translateY(-1px);
}

/* Footer Styling */
.footer {
    border-top: 1px solid var(--border) !important;
    background-color: var(--white) !important;
}
.footer span {
    font-weight: 500;
}

/* Document Number Links Styling (Quotation, Proforma, Invoices, etc.) */
.quot-no-link, .proforma-no-link, .invoice-no-link, .document-no {
    color: #dc3545 !important;
    font-weight: 600 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    text-decoration: none !important;
    transition: color 0.15s ease-in-out !important;
}
.quot-no-link:hover, .proforma-no-link:hover, .invoice-no-link:hover, .document-no:hover {
    color: #a71d2a !important;
    text-decoration: none !important;
}

