/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.gallery-thumb,
.js-gallery-image {
    cursor: zoom-in;
}

.gallery-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.86);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.gallery-lightbox.is-open {
    display: flex;
}

.gallery-lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-lightbox-content img {
    max-width: 95vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 8px;
    background: #ffffff;
    transition: transform 0.12s ease-out;
    transform-origin: center center;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}

.gallery-lightbox-content img.is-zoomed {
    cursor: grab;
}

.gallery-lightbox-content img.is-dragging {
    cursor: grabbing;
}

.gallery-lightbox-close {
    position: fixed;
    top: 18px;
    right: 22px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: #ffffff;
    color: #111827;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 10001;
}

.gallery-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 72px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    font-size: 52px;
    line-height: 1;
    cursor: pointer;
    z-index: 10001;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox-prev {
    left: 24px;
}

.gallery-lightbox-next {
    right: 24px;
}

.gallery-lightbox-counter {
    margin-top: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #111827;
    font-size: 14px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .gallery-lightbox {
        padding: 12px;
    }

    .gallery-lightbox-content img {
        max-width: 96vw;
        max-height: 82vh;
    }

    .gallery-lightbox-nav {
        width: 42px;
        height: 58px;
        font-size: 42px;
    }

    .gallery-lightbox-prev {
        left: 8px;
    }

    .gallery-lightbox-next {
        right: 8px;
    }

    .gallery-lightbox-close {
        top: 10px;
        right: 10px;
    }
}

/* Container */
.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.header-brand:hover {
    text-decoration: none !important;
    color: #111827;
}

.header-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none !important;
    color: #111827;
}

.header-title {
    color: #111827;
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1;
    text-decoration: none !important;
    white-space: nowrap;
}

.brand-mark::after {
    content: '';
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #f97316;
}

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

/* Navigation */
.nav-list {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.nav-link:hover {
    color: #2577ae;
    background-color: #f8f9fa;
}

.nav-link.logout {
    color: #e74c3c;
}

.nav-link.logout:hover {
    color: #c0392b;
    background-color: #fdf2f2;
}

/* Main content */
.main {
    min-height: calc(100vh - 140px);
    padding: 2rem 0;
}

/* Login page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 140px);
}

.login-form {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #2577ae;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background-color: #2577ae;
    color: white;
}

.btn-primary:hover {
    background: #ea580c;
    border-color: #ea580c;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-form .btn {
    width: 100%;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-error {
    background-color: #fdf2f2;
    color: #e74c3c;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #f0f9f4;
    color: #27ae60;
    border: 1px solid #c3e6cb;
}

@media print {
    .print-hidden {
        display: none !important;
    }
}

/* Dashboard */
.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h2 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.dashboard-header p {
    color: #666;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 50%;
}

.stat-content h3 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: #666;
    font-size: 0.9rem;
}

.dashboard-section {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.dashboard-section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Login info */
.login-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #666;
}

.login-info p {
    margin-bottom: 0.25rem;
}

.login-info strong {
    color: #333;
}

/* Footer */
.footer {
    background: #2c3e50;
    color: #ecf0f1;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}

.footer p {
    margin: 0;
    font-size: 0.9rem;
}

/* Error page */
.error {
    text-align: center;
    padding: 4rem 2rem;
}

.error h1 {
    color: #e74c3c;
    margin-bottom: 1rem;
}

.error p {
    color: #666;
    margin-bottom: 2rem;
}

/* Invoice Form */
.invoice-form-container {
    max-width: 100%;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h2 {
    color: #2c3e50;
    margin: 0;
}

.invoice-form {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.form-section {
    padding: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.flex-2 {
    flex: 2;
    min-width: 300px;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background-color: #fff;
}

.form-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-input::placeholder {
    color: #999;
}

select.form-input {
    cursor: pointer;
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

.line-items {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 1rem;
    background-color: #fafafa;
}

.line-item {
    margin-bottom: 0;
}

.form-actions {
    padding: 2rem;
    background-color: #f8f9fa;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
}

/* Invoice Preview */
.invoice-preview-container {
    max-width: 900px;
    margin: 0 auto;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.invoice-preview {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 2rem;
    border-bottom: 2px solid #3498db;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.invoice-title h1 {
    color: #2c3e50;
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    font-weight: 600;
}

.invoice-number {
    color: #666;
    font-size: 1.2rem;
    margin: 0;
}

.invoice-dates {
    text-align: right;
}

.date-item {
    margin-bottom: 0.5rem;
    color: #555;
}

.parties-section {
    display: flex;
    gap: 3rem;
    padding: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.party-info {
    flex: 1;
}

.party-info h3 {
    color: #3498db;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.party-info p {
    margin-bottom: 0.5rem;
    color: #333;
    line-height: 1.6;
}

.line-items-section {
    padding: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.line-items-section h3 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.line-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.line-items-table th {
    background: #f8f9fa;
    color: #2c3e50;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid #3498db;
}

.line-items-table td {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.line-items-table .total-row {
    background: #f8f9fa;
    font-weight: 600;
}

.line-items-table .total-row td {
    border-bottom: none;
    color: #2c3e50;
    font-size: 1.1rem;
}

.notes-section {
    padding: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.notes-section h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.notes-section p {
    color: #555;
    line-height: 1.6;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.preview-actions {
    padding: 2rem;
    background: #f8f9fa;
    text-align: center;
}

.preview-note {
    color: #666;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Responsive invoice preview */
@media (max-width: 768px) {
    .header-actions {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .invoice-header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    
    .invoice-dates {
        text-align: center;
    }
    
    .parties-section {
        flex-direction: column;
        gap: 2rem;
    }
    
    .line-items-table {
        font-size: 0.9rem;
    }
    
    .line-items-table th,
    .line-items-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

/* Responsive invoice form */
@media (max-width: 768px) {
    .page-header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group {
        min-width: 100%;
    }
    
    .form-group.flex-2 {
        min-width: 100%;
    }
    
    .form-section {
        padding: 1.5rem;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-list {
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-form {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        margin-bottom: 0.5rem;
    }
}
