@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    /* padding: 20px; Removed padding from body, will be handled by main-content */
    display: flex;
    flex-direction: column; /* Changed to column for header/footer layout */
    min-height: 100vh;
}

.main-header {
    background-color: #0056b3; /* Dark blue header */
    color: white;
    padding: 10px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.header-container {
    max-width: 1200px; /* Wider container for header */
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    height: 40px; /* Adjust logo size */
    margin-right: 10px;
}

.company-name {
    font-size: 1.5em;
    font-weight: 700;
}

.main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-between; /* Distribute items evenly */
    gap: 15px; /* Minimum space between items */
}

.main-nav li {
    /* margin-left: 25px; Removed for gap */
}

.main-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1em;
    padding: 8px 15px;
    border-radius: 20px;
    transition: background-color 0.3s ease;
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack content vertically */
    justify-content: center; /* Center vertically */
    align-items: center; /* Center horizontally */
}

.main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.user-menu {
    display: flex;
    align-items: center;
}

.user-menu span {
    margin-right: 15px;
    font-weight: 400;
}

.logout-btn {
    background-color: #dc3545;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.logout-btn:hover {
    background-color: #c82333;
}

.main-content {
    flex-grow: 1; /* Allows main content to take available space */
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align content to top */
}

.main-footer-bar {
    background-color: #343a40; /* Dark footer */
    color: white;
    padding: 15px 0;
    text-align: center;
    font-size: 0.9em;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.container {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 900px; /* Increased max-width for content containers */
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 10px;
}

h2 {
    color: #0056b3;
    border-bottom: 2px solid #0056b3;
    padding-bottom: 10px;
    margin-top: 30px;
    margin-bottom: 20px;
}

form {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="email"],
input[type="date"],
textarea,
select {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    border-color: #007bff;
    outline: none;
}

.product-entry {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.remove-product-btn {
    margin-top: 0;
}

.product-entry label {
    display: none; /* Hide labels for product entries as they are implied by placeholders or headers */
}

button, .primary-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    margin-top: 30px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none; /* For <a> tags styled as buttons */
    display: inline-block; /* For <a> tags */
    text-align: center; /* For <a> tags */
}

button:hover, .primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

.secondary-btn {
    background: #6c757d;
    margin-top: 10px;
}

.secondary-btn:hover {
    background: #5a6268;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* New style for back buttons */
.back-btn {
    background-color: transparent;
    color: #007bff;
    border: 1px solid #007bff;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 1em;
    transition: all 0.3s ease;
    display: inline-block;
    margin-bottom: 20px;
}

.back-btn:hover {
    background-color: #007bff;
    color: white;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.2);
}

.errors {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    margin-bottom: 20px;
}

.errors strong {
    font-weight: 600;
}

.errors ul {
    margin: 10px 0 0 20px;
    padding: 0;
}

.errors li {
    margin-bottom: 5px;
}

/* --- Dashboard Styles --- */
.dashboard-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
    margin-top: 20px;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    text-align: center;
}

.stat-card.wide-card {
    grid-column: span 3; /* Make this card wider */
}

.stat-title {
    font-size: 16px;
    font-weight: 500;
    color: #6c757d;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #343a40;
    margin-top: 10px;
}

.top-products-list ol {
    list-style-position: inside;
    padding-left: 0;
    text-align: left;
}

.top-products-list li {
    font-size: 16px;
    color: #495057;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.top-products-list li:last-child {
    border-bottom: none;
}

.top-products-list li span {
    float: right;
    font-weight: 600;
    color: #007bff;
}

/* --- Table Styles (Moved from individual pages) --- */
.table-container {
    width: 100%;
    overflow-x: auto;
}
.sales-table,
.products-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
.sales-table th, .sales-table td,
.products-table th, .products-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}
.sales-table th,
.products-table th {
    background-color: #f2f2f2;
    font-weight: 600;
}
.action-buttons a {
    margin-right: 8px;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 14px;
}
.edit-btn { background-color: #007bff; color: white; }
.delete-btn { background-color: #dc3545; color: white; }
.view-btn { background-color: #6c757d; color: white; }
.add-btn {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    display: inline-block;
    margin-bottom: 20px;
}

/* --- Detail Page Styles (Moved from individual pages) --- */
.detail-container { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
.detail-box { background: #f9f9f9; padding: 20px; border-radius: 8px; }
.detail-box h2 { border-bottom: 2px solid #007bff; padding-bottom: 10px; margin-top: 0; }
.detail-item { margin-bottom: 15px; }
.detail-item strong { display: block; color: #555; margin-bottom: 5px; }
.notes { white-space: pre-wrap; background: #e9ecef; padding: 15px; border-radius: 5px; }

/* Report Menu Styles */
.report-menu {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin-bottom: 30px;
}

.report-menu h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #343a40;
}

.report-menu form {
    display: flex;
    align-items: center;
    gap: 15px;
}

.report-menu .form-group {
    margin-bottom: 0;
}

.report-menu button {
    margin-top: 0;
    width: auto;
    padding: 12px 20px;
}

/* Filter Form Styles */
.filter-form-container {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin-bottom: 30px;
}

.filter-form-container h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #343a40;
}

.filter-form-container .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.filter-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.filter-buttons button,
.filter-buttons a {
    margin-top: 0;
    width: auto;
    padding: 12px 20px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Responsive Styles */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

@media (max-width: 992px) {
    .header-container {
        padding: 0 15px;
        position: relative; /* Establish stacking context */
    }

    .main-nav {
        position: absolute;
        top: 60px; /* Height of the header */
        left: 0;
        width: 100%;
        background-color: #0056b3;
        flex-direction: column;
        align-items: center;
        display: none; /* Hidden by default */
        padding-bottom: 15px;
        z-index: 99; /* Below the toggle button */
    }

    .main-nav.active {
        display: flex;
    }

    .main-nav ul {
        flex-direction: column;
        width: 100%;
        align-items: center;
    }

    .main-nav li {
        margin: 10px 0;
        width: 100%;
        text-align: center;
    }
    
    .main-nav a {
        display: block;
        width: 90%;
        margin: 0 auto;
    }

    .menu-toggle {
        display: block;
        z-index: 100; /* Ensure it's on top */
        background: transparent;
        border: none;
        color: white;
        padding: 5px; /* Keep a small tap area */
        font-size: 28px; /* Slightly larger for easier tapping */
        cursor: pointer;
    }

    .user-menu {
        margin-right: 20px; /* Add space between logout and menu toggle */
    }

    .dashboard-container {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card.wide-card {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .header-container {
        position: relative;
    }
    
    .company-name {
        font-size: 1.2em;
    }

    .form-grid,
    .detail-container {
        grid-template-columns: 1fr;
    }

    .dashboard-container {
        grid-template-columns: 1fr;
    }

    .stat-card.wide-card {
        grid-column: span 1;
    }

    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    .product-entry {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-bottom: 15px;
        border-bottom: 1px solid #eee;
    }

    .product-entry:last-child {
        border-bottom: none;
    }

    .remove-product-btn {
        margin-top: 10px;
    }
    
    .report-menu form {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Summary Section for Sales/Quotations */
.summary-section {
    background-color: #e9f5ff;
    border: 1px solid #b3d7ff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
    text-align: right;
}

.summary-section p {
    margin: 5px 0;
    font-size: 1.1em;
    color: #333;
}

.summary-section h3 {
    margin: 10px 0 0;
    font-size: 1.5em;
    color: #0056b3;
    border: none;
    padding: 0;
}

/* Login Page Header Styles */
.login-header {
    margin-bottom: 30px;
    text-align: center;
}

.login-container .login-logo {
    width: 80px;
    height: auto;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 2em;
    color: #333;
    margin: 0;
}

.login-header p {
    font-size: 1.1em;
    color: #666;
    margin-top: 5px;
}

/* Homepage Header Styles */
.homepage-header {
    margin-bottom: 20px;
    text-align: center;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.homepage-header h1 {
    font-size: 3em;
    color: #333;
    margin: 0;
    position: relative;
    animation: scroll-left-to-right 15s linear infinite;
    white-space: nowrap;
}

.homepage-header p {
    font-size: 1.2em;
    color: #666;
    margin-top: 5px;
}

/* Adjustments for welcome message */
.welcome-message {
    font-size: 2em; /* Adjusted from 2.5em */
}

@keyframes scroll-left-to-right {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}