/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1; /* Indigo 500 */
    --primary-dark: #4f46e5; /* Indigo 600 */
    --secondary-color: #f59e0b; /* Amber 500 */
    --success-color: #10b981; /* Emerald 500 */
    --danger-color: #ef4444; /* Red 500 */
    --warning-color: #f59e0b; /* Amber 500 (same as secondary) */
    --dark-color: #1f2937; /* Gray 800 */
    --light-color: #f9fafb; /* Gray 50 */
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.1);
    --border-radius: 0.5rem;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background-color: var(--gray-100);
    min-height: 100vh;
}

/* App Layout */
.app-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background-color: var(--white);
    box-shadow: var(--shadow-sm);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
}

.app-logo i {
    font-size: 2.2rem;
    color: var(--secondary-color);
}

.app-nav-items {
    display: flex;
    gap: 1.5rem;
}

.app-nav-items .nav-item {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.8rem;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.app-nav-items .nav-item:hover {
    background-color: var(--gray-100);
    color: var(--primary-color);
}

.app-nav-items .nav-item.active {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.app-header .user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-header .user-info button {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.app-header .user-info button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.app-header .pro-status {
    background-color: var(--secondary-color);
    color: var(--white);
    padding: 0.3rem 0.8rem;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 1rem;
}

/* Main Content Area */
.main-container {
    flex: 1;
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    gap: 1.5rem;
}

.sidebar {
    width: 250px;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-nav .nav-item i {
    font-size: 1.2rem;
    color: var(--gray-500);
}

.sidebar-nav .nav-item:hover {
    background-color: var(--gray-100);
    color: var(--primary-color);
}

.sidebar-nav .nav-item.active {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.sidebar-nav .nav-item.active i {
    color: var(--white);
}

.main-content {
    flex: 1;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
}

/* Content Sections */
.content-section {
    display: none; /* Hidden by default */
}

.content-section.active {
    display: block; /* Shown when active */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.section-header h2 {
    font-size: 1.8rem;
    color: var(--gray-900);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626; /* A slightly darker red */
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 1rem;
    color: var(--gray-800);
    background-color: var(--gray-50);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background-color: var(--white);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

.data-table th,
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    text-align: left;
}

.data-table th {
    background-color: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    font-size: 0.85rem;
}

.data-table tbody tr:hover {
    background-color: var(--gray-50);
}

.data-table td .action-buttons button {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 0.5rem;
    transition: color 0.2s ease;
}

.data-table td .action-buttons button:hover {
    color: var(--primary-dark);
}

.data-table td .action-buttons button.delete-btn {
    color: var(--danger-color);
}

.data-table td .action-buttons button.delete-btn:hover {
    color: #dc2626;
}

/* Dashboard Specific Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dashboard-card h3 {
    font-size: 1.1rem;
    color: var(--gray-600);
    margin-bottom: 0.8rem;
}

.dashboard-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.dashboard-card .value.success {
    color: var(--success-color);
}

.dashboard-card .value.danger {
    color: var(--danger-color);
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Invoice Section */
.invoice-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.invoice-party-info {
    background-color: var(--gray-50);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
}

.invoice-party-info h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.invoice-items-table th,
.invoice-items-table td {
    padding: 0.8rem;
    border: 1px solid var(--gray-200);
    text-align: left;
}

.invoice-items-table th {
    background-color: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.invoice-items-table td input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
}

.invoice-summary {
    background-color: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    border: 1px solid var(--gray-200);
    margin-top: 2rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--gray-200);
}

.summary-line:last-child {
    border-bottom: none;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
    padding-top: 1rem;
}

.invoice-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

/* Inventory Section */
.inventory-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.inventory-table .action-buttons button {
    margin-right: 0.5rem;
}

/* Reports Section */
.sales-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.sales-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.sales-card h3 {
    font-size: 1.1rem;
    color: var(--gray-600);
    margin-bottom: 0.8rem;
}

.sales-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.sales-card .value.profit {
    color: var(--success-color);
}

.sales-card .value.loss {
    color: var(--danger-color);
}

/* FanyaBot (AI Assistant) Section */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px); /* Adjust based on header/footer */
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: var(--gray-50);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}

.user-message .message-content {
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 0.8rem 0.8rem 0 0.8rem;
    padding: 0.8rem 1.2rem;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-content {
    background-color: var(--white);
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    border-radius: 0.8rem 0.8rem 0.8rem 0;
    padding: 0.8rem 1.2rem;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.message-avatar {
    width: 30px;
    height: 30px;
    background-color: var(--gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--gray-700);
    flex-shrink: 0;
}

.chat-input {
    display: flex;
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
    background-color: var(--white);
}

.chat-input input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border: 1px solid var(--gray-300);
    border-radius: 2rem;
    font-size: 1rem;
    margin-right: 1rem;
}

.chat-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.chat-input button {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 2rem;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-input button:hover {
    background-color: var(--primary-dark);
}

/* Settings Section */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Modals */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 2000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.5); /* Black w/ opacity */
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s forwards;
}

.modal-content {
    background-color: var(--white);
    margin: auto;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideIn 0.3s forwards;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.modal-close {
    color: var(--gray-500);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.2s ease;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--gray-800);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-body ul {
    list-style: none;
    padding: 0;
}

.modal-body ul li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-700);
}

.modal-body ul li i {
    color: var(--success-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

/* Alerts (Low Stock, etc.) */
.alert {
    display: none;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--warning-color);
    color: var(--white);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert i {
    font-size: 1.5rem;
}

.alert button {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}


/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        padding: 1rem;
    }
    .sidebar {
        width: 100%;
        order: 2; /* Puts sidebar below main content on smaller screens */
    }
    .main-content {
        order: 1; /* Puts main content above sidebar on smaller screens */
        padding: 1.5rem;
    }
    .app-header {
        padding: 1rem;
    }
    .app-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .app-nav-items {
        width: 100%;
        justify-content: space-around;
    }
    .app-header .user-info {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch; /* For smoother scrolling on iOS */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none;  /* IE and Edge */
    }
    .sidebar-nav::-webkit-scrollbar { /* Chrome, Safari, Opera */
        display: none;
    }
    .sidebar-nav .nav-item {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 0.8rem 1.2rem;
    }
    .sidebar-nav .nav-item:hover, .sidebar-nav .nav-item.active {
        border-left: none;
        border-bottom-color: var(--primary-color);
        background-color: var(--gray-100);
        color: var(--primary-color);
    }
    .sidebar-nav .nav-item.active {
        background-color: transparent; /* Remove background for active on horizontal */
        color: var(--primary-color); /* Keep primary color for active text */
    }
    .sidebar-nav .nav-item.active i {
        color: var(--primary-color); /* Keep primary color for active icon */
    }

    .invoice-parties {
        grid-template-columns: 1fr;
    }
    .invoice-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .invoice-actions .btn {
        width: 100%;
    }
    .inventory-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .inventory-controls .btn {
        width: 100%;
    }
    .chat-container {
        height: 60vh;
    }
    .chat-input {
        flex-direction: column;
        gap: 0.8rem;
    }
    .chat-input input {
        margin-right: 0;
    }
    .chat-input button {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .app-logo {
        font-size: 1.4rem;
    }
    .app-logo i {
        font-size: 2rem;
    }
    .app-nav-items {
        gap: 0.8rem;
    }
    .app-nav-items .nav-item {
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .sales-overview {
        grid-template-columns: 1fr;
    }
    .modal-content {
        width: 95%;
        margin: 1rem;
        padding: 1.5rem;
    }
    .modal-header h2 {
        font-size: 1.3rem;
    }
    .modal-close {
        font-size: 1.8rem;
    }
    .invoice-items-table th, .invoice-items-table td {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    .alert {
        width: calc(100% - 2rem);
        left: 1rem;
        right: 1rem;
        transform: none;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 0.8rem;
    }
    .app-nav-items {
        flex-direction: column;
        align-items: flex-start;
    }
    .app-nav-items .nav-item {
        width: 100%;
        text-align: center;
        padding: 0.6rem;
    }
    .main-container {
        padding: 0.5rem;
    }
    .main-content {
        padding: 1rem;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .section-header h2 {
        font-size: 1.5rem;
    }
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    .form-group input, .form-group textarea, .form-group select {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    .data-table th, .data-table td {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
    .dashboard-card .value {
        font-size: 1.5rem;
    }
    .chat-messages {
        height: 50vh;
    }
    .chat-input input {
        font-size: 0.9rem;
    }
}
/* New Main Application Header Styles */
.app-main-header {
    display: flex;
    justify-content: center; /* Center the logo and text horizontally */
    align-items: center;
    padding: 1.5rem 0; /* Add some vertical padding */
    background: var(--white); /* White background for the header */
    box-shadow: var(--shadow-md); /* Subtle shadow */
    margin-bottom: 2rem; /* Space below the header before content sections */
    border-radius: var(--border-radius); /* Rounded corners */
}

.app-logo-main {
    display: flex;
    align-items: center;
    font-family: 'Dancing Script', cursive; /* Use your stylish font for the text */
    font-size: 2.5rem; /* Larger font size for main logo text */
    color: var(--gray-900); /* Dark text color */
}

.app-header-logo-main {
    height: 60px; /* Larger logo size for the main header */
    margin-right: 15px; /* Space between logo and text */
    border-radius: 50%; /* Make the logo circular */
    object-fit: cover; /* Ensures the image covers the area without distortion */
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4); /* Optional: a subtle glow effect */
}
