/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

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

/* Navbar */
.navbar {
    background: #2c3e50;
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.user-email {
    color: #ecf0f1;
    margin-right: 15px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

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

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 15px 30px;
    font-size: 16px;
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.alert-error {
    background: #fadbd8;
    color: #c0392b;
    border-left: 4px solid #e74c3c;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #27ae60;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 450px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.login-header p {
    color: #7f8c8d;
    font-size: 14px;
}

/* Tabs */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #7f8c8d;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: #3498db;
    border-bottom: 2px solid #3498db;
    margin-bottom: -2px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.demo-credentials {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 13px;
}

.demo-credentials p {
    margin: 5px 0;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #3498db;
    margin-bottom: 5px;
}

.stat-label {
    color: #7f8c8d;
    font-size: 14px;
}

.section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.section h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.empty-state p {
    margin-bottom: 20px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.projects-table {
    width: 100%;
    border-collapse: collapse;
}

.projects-table thead {
    background: #f8f9fa;
}

.projects-table th,
.projects-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.projects-table th {
    font-weight: 600;
    color: #2c3e50;
}

.text-muted {
    color: #95a5a6;
}

/* Upload Page */
.upload-page {
    max-width: 800px;
    margin: 0 auto;
}

.upload-card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.upload-dropzone {
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-dropzone:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.upload-dropzone.dragover {
    border-color: #27ae60;
    background: #d5f4e6;
}

.dropzone-content svg {
    color: #95a5a6;
    margin-bottom: 15px;
}

.dropzone-content p {
    margin: 5px 0;
}

.file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
}

.file-item-name {
    flex: 1;
    font-size: 14px;
}

.file-item-size {
    color: #7f8c8d;
    font-size: 12px;
    margin-left: 10px;
}

.file-item-remove {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.upload-requirements {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.upload-requirements h4 {
    margin-bottom: 10px;
}

.upload-requirements ul {
    list-style-position: inside;
    color: #7f8c8d;
    font-size: 14px;
}

.instructions-list {
    list-style-position: inside;
    padding-left: 20px;
}

.instructions-list li {
    margin-bottom: 10px;
}

/* Editor Page */
.editor-container {
    display: flex;
    height: calc(100vh - 60px);
}

.editor-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #ecf0f1;
    overflow-y: auto;
    padding: 20px;
}

.editor-sidebar h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.thumbnail-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 30px;
}

.thumbnail-item {
    position: relative;
    border: 2px solid #ecf0f1;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 180px;
}

.thumbnail-item:hover {
    border-color: #3498db;
}

.thumbnail-item.active {
    border-color: #27ae60;
    box-shadow: 0 0 0 2px #27ae60;
}

.thumbnail-comparison {
    display: flex;
    gap: 3px;
}

.thumbnail-before,
.thumbnail-after {
    flex: 1;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 3px;
    overflow: hidden;
}

.thumbnail-before img,
.thumbnail-after img {
    max-width: 100%;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 3px;
    display: block;
}

.thumbnail-label {
    position: absolute;
    bottom: 3px;
    left: 3px;
    right: 3px;
    background: rgba(0,0,0,0.75);
    color: white;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 2px;
    text-align: center;
}

.thumbnail-placeholder {
    background: #f8f9fa;
    border: 1px dashed #ddd;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-text {
    font-size: 10px;
    color: #95a5a6;
    text-align: center;
    padding: 5px;
}

.thumbnail-number {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
}

.thumbnail-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.thumbnail-delete:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.thumbnail-status {
    margin-top: 5px;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
}

.badge-pending {
    background: #f39c12;
    color: white;
}

.badge-edited {
    background: #27ae60;
    color: white;
}

.bulk-actions {
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
}

.bulk-actions h4 {
    margin-bottom: 15px;
    font-size: 14px;
}

.bulk-actions label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
}

/* Editor Main */
.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}

.editor-header {
    background: white;
    padding: 20px;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h2 {
    color: #2c3e50;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.editor-workspace {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
    overflow: auto;
}

.canvas-container {
    flex: 2;
    background: white;
    border-radius: 8px;
    padding: 50px; /* Extra padding for guides */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: visible;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
}

#editorCanvas {
    border: 1px solid #ddd;
    cursor: move;
    display: block;
    position: relative;
    z-index: 1;
    max-height: 400px; /* Smaller display height */
    max-width: 100%;
    height: auto;
    width: auto;
}

/* Passport Guide Overlays */
.passport-guides {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.passport-guides.hidden {
    display: none;
}

.guide-line {
    position: absolute;
    left: -30px;
    right: -30px;
    height: 0;
    border-top: 2px dashed #0096FF;
    z-index: 10;
}

.guide-line::before,
.guide-line::after {
    content: '';
    position: absolute;
    top: -6px;
    width: 0;
    height: 0;
    border-style: solid;
}

.guide-line::before {
    /* Left arrow */
    left: -30px;
    border-width: 6px 10px 6px 0;
    border-color: transparent #0096FF transparent transparent;
}

.guide-line::after {
    /* Right arrow */
    right: -30px;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #0096FF;
}

.guide-top {
    top: 12%; /* 12% from top = head space */
}

.guide-shoulder {
    top: 85%; /* 85% from top = shoulder level */
}

.guide-label {
    position: absolute;
    left: 5px;
    top: 5px;
    background: white;
    color: #0096FF;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.guide-center-v {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed rgba(0, 150, 255, 0.3);
}

.editor-controls {
    flex: 1;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 300px;
}

.editor-controls h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.control-group input[type="range"] {
    width: 100%;
    margin-right: 10px;
}

/* Zoom Control */
.zoom-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-control input[type="range"] {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 4px;
    outline: none;
}

.zoom-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.zoom-control input[type="range"]::-webkit-slider-thumb:hover {
    background: #2980b9;
}

.zoom-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #333;
}

.zoom-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.zoom-btn:active {
    transform: scale(0.95);
}

#zoomValue {
    min-width: 50px;
    text-align: right;
    font-weight: 500;
    font-size: 14px;
}

.control-group input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-presets {
    display: flex;
    gap: 8px;
}

.color-preset {
    width: 40px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-preset:hover {
    transform: scale(1.1);
    border-color: #3498db;
}

.control-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 13px;
}

.control-info ul {
    list-style-position: inside;
    color: #7f8c8d;
}

.control-info li {
    margin-bottom: 5px;
}

.editor-footer {
    background: white;
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    text-align: center;
}

.pdf-settings {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pdf-settings label {
    margin: 0;
}

.pdf-settings input[type="number"] {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
}

/* Responsive */
/* Mobile & Touch Optimizations */
@media (max-width: 768px) {
    /* Prevent navbar covering content */
    body {
        padding-top: 0;
    }

    /* Layout */
    .editor-container {
        flex-direction: column;
        height: auto; /* Remove fixed height on mobile */
        min-height: calc(100vh - 60px);
    }

    .editor-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ecf0f1;
        padding: 15px;
        position: relative;
        z-index: 1;
        background: white;
    }

    .editor-sidebar h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    /* Make sure thumbnails and add button are visible */
    #addImagesBtn {
        margin-bottom: 10px;
        width: 100%;
    }

    /* Hide bulk actions on mobile to save space */
    .bulk-actions {
        display: none;
    }

    .editor-workspace {
        flex-direction: column;
    }

    .editor-controls {
        max-width: 100%;
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Canvas - make it fit mobile screen */
    .canvas-container {
        max-width: 100%;
        overflow-x: auto;
        padding: 30px 20px; /* Reduce padding on mobile */
    }

    .canvas-wrapper {
        max-width: 100%;
    }

    #editorCanvas {
        max-width: 100%;
        height: auto;
    }

    /* Make guide labels smaller on mobile */
    .guide-label {
        font-size: 9px;
        padding: 2px 5px;
    }

    .guide-line {
        left: -20px;
        right: -20px;
    }

    .guide-line::before {
        left: -20px;
        border-width: 5px 8px 5px 0;
    }

    .guide-line::after {
        right: -20px;
        border-width: 5px 0 5px 8px;
    }

    /* Buttons - larger touch targets */
    .btn {
        min-height: 44px; /* Apple's recommended touch target */
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .btn-block {
        width: 100%;
    }

    /* Thumbnails - horizontal scroll on mobile */
    .thumbnail-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
    }

    .thumbnail-item {
        flex: 0 0 180px; /* Wider for side-by-side comparison */
        min-height: 100px;
        width: 180px;
    }

    .thumbnail-comparison {
        flex-direction: row;
    }

    .thumbnail-before img,
    .thumbnail-after img {
        height: 80px;
    }

    .thumbnail-label {
        font-size: 8px;
        padding: 1px 3px;
    }

    .placeholder-text {
        font-size: 8px;
    }

    /* Toast notifications - adjust for mobile */
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Form inputs - prevent zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="color"],
    select,
    .form-select {
        font-size: 16px;
        min-height: 44px;
    }

    /* Navbar - better mobile spacing */
    .navbar {
        padding: 12px 0;
        position: relative; /* Ensure it's not fixed */
        width: 100%;
    }

    .navbar h1 {
        font-size: 18px;
    }

    .navbar .container {
        padding: 0 15px;
    }

    /* Control groups - better spacing */
    .control-group {
        margin-bottom: 20px;
    }

    /* Color presets - larger touch targets */
    .color-preset {
        width: 36px;
        height: 36px;
    }

    /* Zoom slider - easier to use */
    input[type="range"] {
        height: 36px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .editor-header h2 {
        font-size: 16px;
    }

    .editor-actions {
        flex-direction: column;
        gap: 8px;
    }

    .editor-actions .btn {
        width: 100%;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Form Select Styling */
.form-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    margin-bottom: 5px;
}

.form-select:focus {
    outline: none;
    border-color: #3498db;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid #3498db;
}

.toast.success {
    border-left-color: #27ae60;
}

.toast.error {
    border-left-color: #e74c3c;
}

.toast.warning {
    border-left-color: #f39c12;
}

.toast.info {
    border-left-color: #3498db;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 14px;
}

.toast-message {
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Spinner for loading states */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Button with spinner */
.btn .spinner {
    margin-right: 8px;
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
