/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Theme Colors */
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
}

/* Header */
header {
    background: transparent;
    box-shadow: none;
    padding: 1.5rem 0;
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    text-align: center;
}

/* Footer */
.footer-content {
    text-align: center;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Form Section */
.form-section {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.form-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--surface-color);
    color: var(--text-color);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder, textarea::placeholder {
    color: var(--text-secondary);
}

/* File upload styling */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.logo-upload {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.file-upload-label {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    width: 100%;
    border: none;
}

.file-upload-label:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.file-chosen {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Section Dividers */
.section-divider {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

/* Items Section */
.items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.item-row input {
    margin: 0;
}

.item-total {
    text-align: center;
    font-weight: 600;
    color: var(--text-color);
}

.remove-item {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.remove-item:hover:not(:disabled) {
    background: #dc2626;
}

.remove-item:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.add-item-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 1rem;
    width: 100%;
}

.add-item-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Totals Section */
.totals-section {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    border: 2px solid var(--border-color);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.total-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.grand-total {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--border-color);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
}

/* Preview Section */
.preview-section {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    position: relative;
    height: fit-content;
    min-height: auto;
}

.preview-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.preview-actions {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
}

.invoice-preview {
    background: white;
    padding: 2rem;
    border-radius: 0;
    box-shadow: none;
    border: none;
    color: #1e293b;
}

/* Preview Header */
.preview-header {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.company-info {
    flex: 1;
}

.company-info h2 {
    color: #1f2937;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    text-align: left;
}

.invoice-meta {
    text-align: left;
}

.invoice-meta p {
    color: #374151;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    line-height: 1.2;
}

.logo-container {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#previewLogo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Preview Parties */
.preview-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
}

.party-section {
    padding: 0;
}

.party-section h4 {
    color: #1f2937;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    padding-bottom: 0.5rem;
}

.party-section p {
    margin-bottom: 0.5rem;
    color: #374151;
    font-size: 0.9rem;
}

/* Preview Items */
.preview-items {
    margin-bottom: 2rem;
}

.preview-items table {
    width: 100%;
    border-collapse: collapse;
}

.preview-items th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
}

.preview-items td {
    padding: 1rem;
    color: #374151;
}

.no-items {
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

/* Preview Totals */
.preview-totals {
    padding: 0;
    margin-bottom: 1.5rem;
}

.preview-totals .total-row {
    color: #374151;
}

.preview-totals .grand-total {
    color: #1f2937;
}

/* Preview Notes & Footer */
.preview-notes {
    margin-bottom: 1.5rem;
    padding: 0;
}

.preview-notes p {
    color: #374151;
    margin: 0;
}

.preview-footer {
    text-align: center;
    padding-top: 1rem;
    color: #374151;
}

.preview-footer p {
    margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .items-header, .item-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .items-header span:last-child,
    .item-row .remove-item {
        display: none;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .preview-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .form-section, .preview-section {
        padding: 1.5rem;
    }
    
    .invoice-preview {
        padding: 1rem;
    }
    
    .preview-items th,
    .preview-items td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Mobile-specific button styles */
    .preview-actions {
        position: static;
        display: flex;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
        justify-content: center;
    }
    
    .btn-primary, .btn-secondary {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        min-width: 100px;
    }
    
    .btn-primary {
        background: var(--primary-color);
    }
    
    .btn-secondary {
        background: var(--text-secondary);
    }
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.auth-buttons a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.auth-buttons .btn-secondary {
    background: var(--text-secondary);
    color: white;
    border: none;
}

.auth-buttons .btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
}

.auth-buttons .btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

.auth-buttons .btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Main Navigation Menu */
.main-nav {
    background: var(--surface-color);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border-radius: 8px;
    overflow: hidden;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

.nav-item {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--primary-color);
    background: var(--bg-color);
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-color);
}

/* Blog Page Styles */
.blog-nav {
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 2px solid var(--border-color);
}

.blog-nav .nav-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.blog-nav .nav-link:hover {
    color: var(--primary-hover);
}

.blog-container {
    max-width: 1200px;
    margin: 0 auto;
}

.featured-articles {
    margin-bottom: 3rem;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.article-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.article-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.article-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.read-time, .category {
    background: var(--bg-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.help-docs {
    margin-bottom: 3rem;
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.doc-category h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.doc-links {
    list-style: none;
    padding: 0;
}

.doc-links li {
    margin-bottom: 0.75rem;
}

.doc-links a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.doc-links a:hover {
    color: var(--primary-color);
}

.blog-categories {
    margin-bottom: 3rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.category-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s ease;
}

.category-card:hover {
    transform: translateY(-3px);
}

.category-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.category-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.category-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.category-link:hover {
    color: var(--primary-hover);
}

.blog-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
}

.blog-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.blog-footer a:hover {
    text-decoration: underline;
}

/* Blog Post Styles */
.blog-post {
    margin: 0 auto;
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.post-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.post-date, .read-time, .post-category {
    background: var(--bg-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.blog-post h1, .blog-post h2, .blog-post h3 {
    color: #2c3e50;
    margin-top: 20px;
    margin-bottom: 10px;
}

.post-page .main-content {
    display: block;
}

.post-page .blog-post {
    max-width: 800px;
    margin: 0 auto;
}

.post-content {
    line-height: 1.7;
}

.post-content h2 {
    color: var(--primary-color);
    margin: 2rem 0 1rem 0;
    font-size: 1.5rem;
}

.post-content h3 {
    color: var(--text-color);
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.25rem;
}

.post-content p {
    margin-bottom: 1rem;
}

.post-content ul, .post-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.feature-image {
    margin: 2rem 0;
    text-align: center;
}

.image-placeholder {
    background: var(--bg-color);
    border: 2px dashed var(--border-color);
    padding: 3rem;
    border-radius: 8px;
    color: var(--text-secondary);
}

.image-caption {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

.call-to-action {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: 12px;
    margin: 2rem 0;
    border: 2px solid var(--border-color);
    text-align: center;
}

.cta-button {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.cta-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.post-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.post-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.nav-button {
    background: var(--surface-color);
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.nav-button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-button.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-button.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}


/* Auth Page Styles */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.auth-container {
    background-color: var(--background-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-background);
    color: var(--text-color);
}

.auth-error {
    color: #e53e3e;
    margin-bottom: 1rem;
    display: none;
}

.auth-success {
    color: #38a169;
    margin-bottom: 1rem;
    display: none;
}

.auth-container p {
    text-align: center;
    margin-top: 1rem;
}

.auth-container a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-container a:hover {
    text-decoration: underline;
}

/* Responsive Styles */
@media (max-width: 480px) {
    .auth-container {
        padding: 1.5rem;
    }
}

/* Print Styles */
@media print {
    .form-section,
    .form-actions {
        display: none !important;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .invoice-preview {
        box-shadow: none;
        border: none;
    }
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 6px;
}

/* Animation for smooth transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
