/* Global Styles */
:root {
    --primary-color: #4361ee;
    --primary-light: #4895ef;
    --primary-dark: #3f37c9;
    --secondary-color: #2b2d42;
    --accent-color: #f72585;
    --success-color: #4cc9f0;
    --warning-color: #f8961e;
    --light-gray: #f8f9fa;
    --lighter-gray: #ffffff;
    --medium-gray: #e9ecef;
    --dark-gray: #6c757d;
    --darker-gray: #343a40;
    --text-color: #2b2d42;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.08);
    --shadow-large: 0 10px 25px rgba(0, 0, 0, 0.12);
    --border-color: #e9ecef;
    --border-radius: 10px;
    --border-radius-lg: 14px;
    --border-radius-sm: 6px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
}

/* Theme Variables */
body.theme-default {
    --primary-color: #4361ee;
    --primary-light: #4895ef;
    --primary-dark: #3f37c9;
    --secondary-color: #2b2d42;
    --accent-color: #f72585;
}

body.theme-green {
    --primary-color: #2ec4b6;
    --primary-light: #52b788;
    --primary-dark: #2d6a4f;
    --secondary-color: #212529;
    --accent-color: #ff9f1c;
}

body.theme-purple {
    --primary-color: #7209b7;
    --primary-light: #9d4edd;
    --primary-dark: #560bad;
    --secondary-color: #22223b;
    --accent-color: #f72585;
}

body.theme-red {
    --primary-color: #e63946;
    --primary-light: #f94144;
    --primary-dark: #d00000;
    --secondary-color: #1d3557;
    --accent-color: #ffb703;
}

/* Dark Theme Variables */
.dark-theme {
    --primary-color: #4895ef;
    --primary-light: #4cc9f0;
    --primary-dark: #4361ee;
    --secondary-color: #141b2d;
    --light-gray: #1f2940;
    --lighter-gray: #283252;
    --medium-gray: #4d5b7c;
    --dark-gray: #e0e0e0;
    --darker-gray: #f5f5f5;
    --text-color: #f8f9fa;
    --white: #283252;
    --border-color: #384766;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-large: 0 12px 40px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--light-gray);
    font-size: 14px;
    letter-spacing: 0.2px;
}

/* App Layout */
.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    background-color: var(--light-gray);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow);
}

.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.sidebar-header span {
    color: var(--secondary-color);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--dark-gray);
    font-size: 22px;
    cursor: pointer;
    display: none;
    transition: var(--transition);
}

.menu-toggle:hover {
    color: var(--primary-color);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--dark-gray);
    border-left: 3px solid transparent;
    transition: var(--transition);
    margin-bottom: 4px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.sidebar-nav li i {
    margin-right: 15px;
    width: 22px;
    text-align: center;
    font-size: 18px;
    transition: var(--transition);
}

.sidebar-nav li:hover {
    background-color: var(--lighter-gray);
    color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar-nav li.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    background-color: rgba(67, 97, 238, 0.1);
    font-weight: 600;
}

.sidebar-nav li.active i {
    transform: scale(1.1);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-block {
    width: 100%;
    margin-bottom: 12px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    color: var(--dark-gray);
    font-weight: 500;
}

/* Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--medium-gray);
    transition: var(--transition);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--white);
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: var(--light-gray);
}

.main-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background-color: var(--lighter-gray);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.main-header h2 {
    font-size: 22px;
    color: var(--secondary-color);
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.content-wrapper {
    display: flex;
    flex: 1;
    padding: 25px;
    gap: 25px;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

.form-container {
    flex: 1;
    background-color: var(--lighter-gray);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.form-section {
    display: none;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
    background-color: var(--lighter-gray);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.form-section.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background-color: var(--lighter-gray);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.section-header h3 {
    font-size: 18px;
    color: var(--secondary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header h3 i {
    color: var(--primary-color);
    font-size: 20px;
}

.section-toggle {
    color: var(--dark-gray);
    font-size: 16px;
    transition: var(--transition);
}

.section-toggle.collapsed {
    transform: rotate(180deg);
}

.section-content {
    padding: 25px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
    width: 100%;
}

.form-row .form-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--secondary-color);
    font-size: 14px;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    color: var(--text-color);
    background-color: var(--lighter-gray);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Button styling */
button {
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: var(--border-radius-sm);
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: 0 2px 5px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(67, 97, 238, 0.3);
}

.btn-secondary {
    background-color: var(--medium-gray);
    color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: var(--dark-gray);
    color: var(--white);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--dark-gray);
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--primary-color);
    background-color: rgba(67, 97, 238, 0.1);
}

/* File Upload Styling */
.file-upload {
    display: flex;
    align-items: center;
    position: relative;
    margin-bottom: 10px;
}

.file-upload input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.btn-upload {
    padding: 8px 12px;
    flex-shrink: 0;
}

.file-name {
    margin-left: 10px;
    color: var(--dark-gray);
    font-size: 13px;
}

.logo-preview {
    width: 100px;
    height: 100px;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
}

/* Items Table Styling */
.items-table {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    background-color: var(--lighter-gray);
}

.item-header {
    display: grid;
    grid-template-columns: 2fr 3fr 1fr 1fr 1fr auto;
    padding: 15px;
    background-color: var(--lighter-gray);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--secondary-color);
}

.item-header div {
    padding: 0 10px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 3fr 1fr 1fr 1fr auto;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: var(--transition);
}

.item-row:hover {
    background-color: rgba(67, 97, 238, 0.03);
}

.item-row:last-child {
    border-bottom: none;
}

.item-row .form-group {
    margin-bottom: 0;
    padding: 0 10px;
}

.item-row textarea {
    height: 80px;
    resize: vertical;
}

.item-row input, .item-row textarea {
    border-color: transparent;
    background-color: rgba(233, 236, 239, 0.3);
    transition: var(--transition);
}

.item-row input:focus, .item-row textarea:focus {
    background-color: var(--white);
    border-color: var(--primary-color);
}

.amount-value {
    display: inline-block;
    min-width: 80px;
    font-weight: 600;
    color: var(--primary-color);
    text-align: right;
    font-size: 15px;
}

.item-actions {
    display: flex;
    justify-content: center;
}

.delete-item {
    color: var(--accent-color);
    background-color: transparent;
    opacity: 0.7;
    transition: var(--transition);
}

.delete-item:hover {
    opacity: 1;
    transform: scale(1.1);
    background-color: rgba(247, 37, 133, 0.1);
}

#addItemBtn {
    margin-bottom: 25px;
    transition: var(--transition);
}

#addItemBtn:hover {
    transform: translateY(-2px);
}

/* Totals Section */
.totals-section {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary-color);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.totals-row:last-child {
    border-bottom: none;
}

.totals-row span:first-child {
    font-weight: 500;
    color: var(--secondary-color);
}

.totals-row.total {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid var(--border-color);
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-color);
}

.custom-total-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-total-wrapper input {
    width: 150px;
}

/* Settings Styles */
.settings-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.settings-section h4 {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--secondary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-section h4 i {
    color: var(--primary-color);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-item label {
    margin-bottom: 0;
}

.settings-item input[type="text"],
.settings-item input[type="number"],
.settings-item select {
    width: 200px;
}

/* Theme Selection */
.theme-selection {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.theme-option {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow);
}

.theme-option::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 30px;
    height: 30px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    transition: var(--transition);
}

.theme-option.active {
    border-color: var(--white);
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.theme-option.active::after {
    transform: translate(-50%, -50%) scale(1);
}

.theme-option:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
}

/* Help Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--lighter-gray);
    margin: 5% auto;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-large);
    width: 80%;
    max-width: 800px;
    animation: modalContentSlideIn 0.3s forwards;
    position: relative;
}

@keyframes modalContentSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--secondary-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h2 i {
    color: var(--primary-color);
}

.close {
    color: var(--dark-gray);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.close:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Mobile Responsiveness */
.mobile-menu-button {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-large);
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.mobile-menu-button:hover {
    transform: scale(1.1);
    background-color: var(--primary-dark);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.5s forwards;
}

.slide-up {
    animation: slideUp 0.5s forwards;
}

/* Hover animations for buttons */
.btn-primary, .btn-secondary, .btn-action {
    position: relative;
    overflow: hidden;
}

.btn-primary::after, .btn-secondary::after, .btn-action::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn-primary:hover::after, .btn-secondary:hover::after, .btn-action:hover::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

/* Print Styles */
@media print {
    body, .invoice-preview {
        background-color: white;
        padding: 0;
        margin: 0;
    }
    
    .app-wrapper, .main-content, .content-wrapper, .preview-container {
        width: 100%;
        height: auto;
        overflow: visible;
        display: block;
    }
    
    .sidebar, 
    .main-header, 
    .preview-header, 
    .form-container, 
    #helpModal {
        display: none !important;
    }
    
    .invoice-preview {
        box-shadow: none;
    }
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .content-wrapper {
        flex-direction: column;
    }
    
    .form-container, .preview-container {
        width: 100%;
        max-width: 100%;
    }
    
    .invoice-preview {
        padding: 20px;
    }
    
    .invoice-template {
        padding: 30px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 1000;
        top: 0;
        left: 0;
        height: 100vh;
        width: var(--sidebar-width);
        box-shadow: var(--shadow-large);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .menu-toggle, .mobile-menu-button {
        display: flex;
    }
    
    .main-content {
        width: 100%;
    }
    
    .main-header {
        padding: 0 20px;
    }
    
    .item-header, .item-row {
        grid-template-columns: 1.5fr 2fr 0.8fr 1fr 0.8fr auto;
    }
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .content-wrapper {
        padding: 15px;
    }
    
    .modal-content {
        width: 90%;
        padding: 20px;
    }
    
    .item-header {
        display: none;
    }
    
    .item-row {
        display: flex;
        flex-direction: column;
        padding: 15px;
        border-bottom: 1px solid var(--border-color);
        border-radius: var(--border-radius-sm);
        margin-bottom: 10px;
        background-color: var(--lighter-gray);
        box-shadow: var(--shadow);
    }
    
    .item-row .form-group {
        margin-bottom: 10px;
        position: relative;
        padding-top: 25px;
    }
    
    .item-row .form-group::before {
        content: attr(data-label);
        position: absolute;
        top: 0;
        left: 10px;
        font-size: 12px;
        font-weight: 600;
        color: var(--primary-color);
    }
    
    .items-table {
        box-shadow: none;
    }
    
    .item-actions {
        align-self: flex-end;
    }
    
    .invoice-header, 
    .invoice-metadata,
    .invoice-title {
        flex-direction: column;
    }
    
    .company-info, 
    .invoice-dates {
        text-align: left;
        margin-top: 20px;
    }
    
    .invoice-totals {
        width: 100%;
    }
    
    .totals-section {
        width: 100%;
    }
    
    .theme-selection {
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .main-header h2 {
        font-size: 18px;
    }
    
    .section-header h3 {
        font-size: 16px;
    }
    
    .section-content {
        padding: 15px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .btn-action {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .preview-actions {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .invoice-template {
        padding: 20px;
    }
    
    .invoice-title h1 {
        font-size: 24px;
    }
    
    .company-info h2 {
        font-size: 20px;
    }
}

/* Improved Form Fields */
input, select, textarea {
    background-color: var(--lighter-gray);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

input:hover, select:hover, textarea:hover {
    border-color: #c0c0c0;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
    outline: none;
}

.form-group {
    position: relative;
}

select {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%236c757d" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

[type="date"] {
    position: relative;
}

[type="date"]::-webkit-calendar-picker-indicator {
    background: transparent;
    color: transparent;
    cursor: pointer;
    height: 100%;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
}

/* Loading State */
.loading-state {
    position: relative;
}

.loading-state::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.loading-state::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid var(--primary-light);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spinner 0.8s linear infinite;
    z-index: 11;
}

@keyframes spinner {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Print styles for invoice */
@media print {
    body {
        background-color: white;
        font-size: 12pt;
    }
    
    .app-wrapper, .main-content, .content-wrapper, .preview-container, .invoice-preview {
        display: block;
        width: 100%;
        height: auto;
        overflow: visible;
        background-color: white;
        padding: 0;
        margin: 0;
    }
    
    .sidebar, .main-header, .preview-header, .form-container, .mobile-menu-button {
        display: none !important;
    }
    
    .invoice-template {
        box-shadow: none;
        padding: 0;
        margin: 0;
        max-width: 100%;
        width: 100%;
    }
    
    @page {
        margin: 0.5cm;
    }
}

/* Preview Container */
.preview-container {
    flex: 1;
    background-color: var(--lighter-gray);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.preview-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--lighter-gray);
}

.preview-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-header h3 i {
    color: var(--primary-color);
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.btn-action {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 8px 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-action:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}

.btn-action:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-action.btn-print {
    background-color: var(--success-color);
}

.btn-action.btn-download {
    background-color: var(--secondary-color);
}

.btn-action.btn-email {
    background-color: var(--accent-color);
}

.invoice-preview {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background-color: var(--light-gray);
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--dark-gray);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Invoice Template Styles - Original Style */
.invoice-template {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    padding: 30px;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    max-width: 800px;
    margin: 0 auto;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.company-logo {
    max-width: 150px;
    height: auto;
}

.company-logo img {
    max-width: 100%;
    max-height: 100px;
    object-fit: contain;
}

.company-info {
    text-align: right;
}

.company-info h2 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 10px;
    font-weight: 600;
}

.company-info p {
    margin-bottom: 5px;
    color: var(--dark-gray);
}

.invoice-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.invoice-title h1 {
    color: var(--primary-color);
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
}

.invoice-title .invoice-number {
    font-size: 18px;
    font-weight: bold;
    color: var(--accent-color);
}

.invoice-metadata {
    background-color: var(--light-gray);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
}

.invoice-details {
    flex: 1;
}

.invoice-details p, .invoice-dates p {
    margin-bottom: 5px;
}

.invoice-dates {
    flex: 1;
    text-align: right;
}

.invoice-items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.invoice-items th {
    background-color: var(--primary-color);
    color: var(--white);
    text-align: left;
    padding: 12px;
    font-weight: 600;
}

.invoice-items tr:nth-child(even) {
    background-color: var(--light-gray);
}

.invoice-items td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-items td:nth-child(3) {
    text-align: center;
}

.invoice-items td:nth-child(4), .invoice-items td:nth-child(5) {
    text-align: right;
}

.invoice-totals {
    width: 300px;
    margin-left: auto;
    margin-bottom: 30px;
}

.invoice-totals tr {
    border-bottom: 1px solid var(--border-color);
}

.invoice-totals td {
    padding: 10px;
}

.invoice-totals td:last-child {
    text-align: right;
}

.total-row {
    font-weight: bold;
    font-size: 18px;
    color: var(--primary-color);
}

.total-row td {
    padding-top: 15px !important;
}

.invoice-notes {
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--light-gray);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--primary-color);
}

.invoice-notes h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 600;
}

.invoice-notes p {
    margin: 0;
    color: var(--dark-gray);
}

.invoice-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--dark-gray);
    font-size: 14px;
}

/* Custom Items Display (for when custom total is used) */
.custom-items {
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 15px;
    background-color: var(--light-gray);
}

.custom-items h3 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    font-size: 16px;
    font-weight: 600;
}

.item-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.item-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.item-list li:last-child {
    border-bottom: none;
}

.custom-item-name {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--secondary-color);
}

.custom-item-description {
    color: var(--dark-gray);
}

/* Dark Theme Invoice Template */
.dark-invoice-template {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: white;
    padding: 30px;
    background-color: #1f2b4e;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    max-width: 800px;
    margin: 0 auto;
}

.dark-invoice-template .invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.dark-invoice-template .company-logo {
    max-width: 150px;
    height: auto;
}

.dark-invoice-template .company-logo img {
    max-width: 100%;
    max-height: 100px;
    object-fit: contain;
}

.dark-invoice-template .company-info {
    text-align: right;
    color: white;
}

.dark-invoice-template .company-info h2 {
    color: #a166ff;
    font-size: 24px;
    margin-bottom: 10px;
    font-weight: 600;
}

.dark-invoice-template .company-info p {
    margin-bottom: 5px;
    color: white;
}

.dark-invoice-template .invoice-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.dark-invoice-template .invoice-title h1 {
    color: #a166ff;
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
}

.dark-invoice-template .invoice-title .invoice-number {
    font-size: 18px;
    font-weight: bold;
    color: #ff4d6d;
}

.dark-invoice-template .invoice-metadata {
    background-color: #192340;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    color: white;
}

.dark-invoice-template .invoice-details {
    flex: 1;
}

.dark-invoice-template .invoice-details p, 
.dark-invoice-template .invoice-dates p {
    margin-bottom: 5px;
    color: white;
}

.dark-invoice-template .invoice-dates {
    flex: 1;
    text-align: right;
}

.dark-invoice-template .items-container {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 25px;
}

.dark-invoice-template .items-title {
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
}

.dark-invoice-template .items-content {
    padding: 10px 0;
    color: #333;
}

.dark-invoice-template .total-container {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-left: auto;
    width: 300px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
}

.dark-invoice-template .total-label {
    font-weight: 600;
    color: #a166ff;
}

.dark-invoice-template .total-value {
    font-weight: 600;
    color: #333;
}

.dark-invoice-template .invoice-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Theme toggle for invoice style */
.invoice-style-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 15px;
    background-color: var(--lighter-gray);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow);
}

.invoice-style-options {
    display: flex;
    gap: 10px;
}

.style-option {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
    overflow: hidden;
}

.style-option.light {
    background-color: white;
    position: relative;
}

.style-option.light::after {
    content: "";
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 2px;
    background-color: #4361ee;
}

.style-option.dark {
    background-color: #1f2b4e;
    position: relative;
}

.style-option.dark::after {
    content: "";
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 2px;
    background-color: #a166ff;
}

.style-option.active {
    transform: scale(1.1);
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
} 