/* 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-color: #f5f5f5;
}

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

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 4px 0;
    margin-bottom: 2rem;
}

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

.navbar h1 {
    margin: 0;
}

.navbar h1 a {
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar .nav-logo {
    height: 43px;
    width: auto;
    display: block;
    vertical-align: middle;
}

.navbar .nav-brand-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 3px;
    transition: background-color 0.3s;
}

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

.nav-user-email {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    padding: 5px 10px;
}

.nav-logout-form {
    margin: 0;
}

.nav-logout-btn {
    background: none;
    border: none;
    color: white;
    font: inherit;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 3px;
    transition: background-color 0.3s;
}

.nav-logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

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

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

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

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

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

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eee;
}

/* Preview */
.preview-wrapper {
    margin: 1rem 0;
    display: block !important;
    visibility: visible !important;
    width: auto;
    height: auto;
}

.preview-element {
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    background: transparent;
}

.preview-graphic {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100%;
    height: 100%;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.preview-graphic img,
.preview-graphic object {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Scale to fit while maintaining aspect ratio */
    position: absolute;
    top: 0;
    left: 0;
}

/* For SVG graphics using background-image approach */
.preview-graphic > div,
.preview-graphic .svg-stretch-container {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
}

.preview-graphic object {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    display: block !important;
}

.preview-container {
    min-height: 0;
    display: block !important;
    margin-top: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

.preview-container:empty {
    display: block;
    min-height: 0;
}

.preview-container:empty::before {
    content: "No graphic assigned";
    color: #999;
    font-size: 12px;
}

/* Gate builder */
.gate-builder {
    display: grid;
    gap: 1.5rem;
}

.element-config {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.element-config h4 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.element-info {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.element-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.1s;
}

.element-item:hover {
    background: #e9ecef;
}

.element-item[onclick]:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.elements-list {
    margin-top: 0.5rem;
}

.graphic-selector {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.graphic-upload,
.graphic-picker {
    flex: 1;
}

.file-upload-area {
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s;
}

.file-upload-area:hover {
    border-color: #007bff;
}

.file-upload-area.dragover {
    border-color: #007bff;
    background-color: #f0f8ff;
}

/* Order summary */
.order-summary {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
}

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

.order-summary th,
.order-summary td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.order-summary th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* QA Review */
.qa-review {
    max-width: 900px;
}

.qa-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-draft { background-color: #6c757d; color: white; }
.status-submitted { background-color: #17a2b8; color: white; }
.status-qa-pending { background-color: #ffc107; color: #000; }
.status-qa-approved { background-color: #28a745; color: white; }
.status-qa-rejected { background-color: #dc3545; color: white; }
.status-payment_received { background-color: #007bff; color: white; }
.status-sent { background-color: #007bff; color: white; }

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Predefined graphic picker as thumbnail list */
.graphic-picker-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.graphic-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    padding: 6px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.graphic-picker-item:hover {
    border-color: #6c757d;
    background: #f8f9fa;
}

.graphic-picker-item.selected {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.graphic-picker-item img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    background: #f8f9fa;
}

.graphic-picker-item .graphic-picker-name {
    font-size: 0.7rem;
    text-align: center;
    margin-top: 4px;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graphic-picker-item .graphic-picker-placeholder {
    width: 56px;
    height: 56px;
    background: #e9ecef;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #6c757d;
    text-align: center;
}

/* Predefined graphic modal - true overlay on top of page */
.predefined-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.predefined-modal-overlay.is-open {
    display: flex !important;
}

.predefined-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.predefined-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
}

.predefined-modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.predefined-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
    padding: 0 0.25rem;
}

.predefined-modal-close:hover {
    color: #333;
}

.predefined-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.predefined-modal .graphic-picker-thumbnails {
    max-height: 60vh;
}

/* Modal: 50% bigger thumbnails and full file name */
.predefined-modal .graphic-picker-item {
    width: 130px;
    padding: 8px;
}

.predefined-modal .graphic-picker-item img {
    width: 84px;
    height: 84px;
}

.predefined-modal .graphic-picker-item .graphic-picker-placeholder {
    width: 84px;
    height: 84px;
    font-size: 0.75rem;
}

.predefined-modal .graphic-picker-item .graphic-picker-name {
    font-size: 0.75rem;
    margin-top: 6px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
    max-width: 120px;
    line-height: 1.25;
}
