/* Invoice Generator - Main Stylesheet */

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.5;
}

.btn-primary {
    background-color: #007bff;
    border-color: #007bff;
    color: #fff;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #545b62;
    border-color: #545b62;
    color: #fff;
    text-decoration: none;
}

.btn-outline {
    background-color: transparent;
    border-color: #007bff;
    color: #007bff;
}

.btn-outline:hover {
    background-color: #007bff;
    color: #fff;
    text-decoration: none;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #c82333;
    color: #fff;
    text-decoration: none;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: #dc3545;
}

.form-group input.success,
.form-group select.success,
.form-group textarea.success {
    border-color: #28a745;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Phone Input */
.phone-input {
    display: flex;
    align-items: center;
}

.country-code {
    padding: 0.75rem;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-right: none;
    border-radius: 0.375rem 0 0 0.375rem;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.phone-input input {
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Password Strength Indicator */
.password-strength {
    margin-top: 0.5rem;
}

.strength-bar {
    height: 4px;
    background-color: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.strength-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.strength-fill.weak {
    background-color: #dc3545;
}

.strength-fill.medium {
    background-color: #ffc107;
}

.strength-fill.strong {
    background-color: #28a745;
}

.strength-text {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* Alerts */
.alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Authentication Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    color: #007bff;
    margin-bottom: 0.5rem;
}

.auth-header h2 {
    color: #6c757d;
    font-weight: 400;
}

.auth-form {
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}

.auth-footer p {
    margin-bottom: 0.5rem;
    color: #6c757d;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: #2c3e50;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid #34495e;
}

.sidebar-header h2 {
    color: #fff;
    margin-bottom: 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 1rem 0;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
}

.sidebar-nav a {
    display: block;
    padding: 1rem 1.5rem;
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background-color: #34495e;
    color: #fff;
    text-decoration: none;
}

.main-content {
    flex: 1;
    padding: 2rem;
    background-color: #f8f9fa;
    overflow-x: auto;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.content-header h1 {
    margin-bottom: 0;
    color: #2c3e50;
}

.user-info {
    color: #6c757d;
    font-weight: 500;
}

/* Statistics Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 50%;
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: #6c757d;
    margin-bottom: 0;
    font-weight: 500;
}

.stat-card.total-amount .stat-icon {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
}

/* Quick Actions */
.quick-actions {
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.quick-actions h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-icon {
    margin-right: 0.5rem;
}

/* Tables */
.invoice-table,
.invoices-table {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.invoice-table table,
.invoices-table table {
    width: 100%;
    border-collapse: collapse;
}

.invoice-table th,
.invoice-table td,
.invoices-table th,
.invoices-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.invoice-table th,
.invoices-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.invoice-table tbody tr:hover,
.invoices-table tbody tr:hover {
    background-color: #f8f9fa;
}

.invoice-link {
    font-weight: 600;
    color: #007bff;
}

.status {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-draft {
    background-color: #ffc107;
    color: #856404;
}

.status-sent {
    background-color: #17a2b8;
    color: #0c5460;
}

.status-paid {
    background-color: #28a745;
    color: #155724;
}

.status-overdue {
    background-color: #dc3545;
    color: #721c24;
}

.overdue-indicator {
    color: #dc3545;
    margin-left: 0.5rem;
}

.table-footer {
    padding: 1rem;
    text-align: center;
    background-color: #f8f9fa;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.empty-state h3 {
    color: #6c757d;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #6c757d;
    margin-bottom: 2rem;
}

/* Invoice Form */
.invoice-form {
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.form-section {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e9ecef;
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
}

/* Invoice Items */
.items-container {
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid #e9ecef;
    align-items: center;
}

.item-row:first-child {
    border-top: none;
}

.item-col-desc input,
.item-col-qty input,
.item-col-price input,
.item-col-total input {
    margin-bottom: 0;
}

/* Calculations */
.calculations-grid {
    max-width: 400px;
    margin-left: auto;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.calc-row:last-child {
    border-bottom: none;
}

.calc-row.total-row {
    font-weight: 700;
    font-size: 1.125rem;
    border-top: 2px solid #2c3e50;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.calc-row label {
    font-weight: 500;
    margin-bottom: 0;
}

.calc-row input {
    width: 100px;
    margin-bottom: 0;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

/* Filters */
.filters-section {
    background: #fff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.filters-form {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group input,
.filter-group select {
    margin-bottom: 0;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-top: 2rem;
}

.page-info {
    color: #6c757d;
    font-weight: 500;
}

/* Action Buttons */
.status-form {
    display: inline-block;
}

.status-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: #fff;
}

/* Recent Invoices */
.recent-invoices {
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.recent-invoices h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

/* --- UPDATED: Invoice Actions Section --- */
.invoice-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem; /* This adds space between the 'Back' button and the group on the right */
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.invoice-actions .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem; /* This adds space between the Edit, Print, and PDF buttons */
}
/* --- END OF UPDATE --- */

/* Invoice Container */
.invoice-container {
    background: #fff;
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    max-width: 800px;
    margin: 0 auto;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e9ecef;
}

.company-info h1 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.company-info p {
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.invoice-info {
    text-align: right;
}

.invoice-info h2 {
    color: #007bff;
    margin-bottom: 1rem;
}

.invoice-info p {
    margin-bottom: 0.5rem;
}

.client-info {
    margin-bottom: 3rem;
}

.client-info h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.client-details p {
    margin-bottom: 0.25rem;
    color: #6c757d;
}

.invoice-items {
    margin-bottom: 3rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    overflow: hidden;
}

.items-table th {
    background-color: #f8f9fa;
    padding: 1rem;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 1px solid #e9ecef;
}

.items-table td {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

.invoice-totals {
    margin-bottom: 3rem;
}

.totals-table {
    max-width: 400px;
    margin-left: auto;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.total-row:last-child {
    border-bottom: none;
}

.final-total {
    font-weight: 700;
    font-size: 1.25rem;
    border-top: 2px solid #2c3e50;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.invoice-notes {
    margin-bottom: 3rem;
}

.invoice-notes h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.invoice-footer {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
}

/* Print Styles */
.no-print {
    display: block;
}

@media print {
    .no-print {
        display: none !important;
    }
    
    .invoice-container {
        box-shadow: none;
        padding: 0;
    }
    
    body {
        background: #fff;
    }
}

/* Demo Info */
.admin-demo-info {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.demo-card {
    background: #fff;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #007bff;
    max-width: 250px;
}

.demo-card h3 {
    color: #007bff;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.demo-card p {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: #6c757d;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        order: 2;
    }
    
    .main-content {
        order: 1;
        padding: 1rem;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-row .form-group {
        margin-bottom: 1.5rem;
    }
    
    .items-header,
    .item-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .items-header {
        display: none;
    }
    
    .item-row {
        border: 1px solid #e9ecef;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .item-row:last-child {
        margin-bottom: 0;
    }
    
    .calculations-grid {
        max-width: none;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .filters-form {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: auto;
    }
    
    .pagination {
        flex-direction: column;
        gap: 1rem;
    }
    
    .invoice-header {
        flex-direction: column;
        gap: 2rem;
    }
    
    .invoice-info {
        text-align: left;
    }
    
    .invoice-container {
        padding: 1.5rem;
    }
    
    .auth-container {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 2rem;
    }
    
    .demo-card {
        position: relative;
        margin-top: 2rem;
    }
    
    .admin-demo-info {
        position: static;
        display: flex;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.5rem;
    }
    
    .invoice-container {
        padding: 1rem;
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    
    .items-table {
        font-size: 0.875rem;
    }
    
    .items-table th,
    .items-table td {
        padding: 0.5rem;
    }
}