/* Base styles */
:root {
    --primary-color: #4a6fa5;
    --secondary-color: #b31571;
    --accent-color: #f48c06;
    --accent-color-rgb: 244, 140, 6;
    --text-color: #333;
    --light-color: #f9f9f9;
    --border-color: #ddd;
    --success-color: #28a745;
    --success-color-rgb: 40, 167, 69;
    --error-color: #dc3545;
    --error-color-rgb: 220, 53, 69;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-color);
    padding: 0;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout */
header {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin-bottom: 0.5rem;
}

footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
}

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

footer p::before {
    content: "🔧 ";
    margin-right: 0.25rem;
}

/* Navigation */
nav {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: 500;
    white-space: nowrap;
    display: inline-block;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-link.logout-link {
    margin-left: auto;
}

/* Additional logout link styling for enhanced visibility */
.nav-link.logout-link {
    background-color: rgba(var(--error-color-rgb), 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.nav-link.logout-link:hover {
    background-color: var(--error-color);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

/* Responsive navigation */
@media (max-width: 768px) {
    nav {
        margin-top: 0.75rem;
        gap: 0.25rem;
    }
    
    .nav-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .nav-link.logout-link {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    nav {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
        max-width: 200px;
    }
}

main {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

section {
    margin-bottom: 2.5rem;
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"], 
input[type="file"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #3a5a8c;
}

.primary-btn.processing {
    position: relative;
    cursor: wait;
    background-color: #4a6fa5;
    opacity: 0.85;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.edit-date-btn .spinner {
    width: 12px;
    height: 12px;
    margin-right: 0;
}

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

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 4px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.dropzone:hover {
    border-color: var(--primary-color);
}

.dropzone input[type="file"] {
    display: none;
}

/* Preview */
.preview {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    width: 150px;
    height: 150px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.preview-item.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.05);
    animation: pulse 1.5s infinite;
}

.preview-item.error {
    border-color: var(--error-color);
    background-color: rgba(220, 53, 69, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-item.processed {
    border-color: var(--success-color);
    box-shadow: 0 0 5px rgba(var(--success-color-rgb), 0.5);
    position: relative;
}

.preview-item.processed::after {
    content: "✓";
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: var(--success-color);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.preview-item.loading p, 
.preview-item.error p {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
}

.preview-item.error p {
    color: var(--error-color);
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Templates and Logos grid */
.template-grid,
.logo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.template-item,
.logo-item {
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
}

.template-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.template-item:hover {
    background-color: rgba(var(--accent-color-rgb), 0.1);
}

.template-item.selected,
.logo-item.selected {
    border-color: var(--accent-color);
    background-color: rgba(var(--accent-color-rgb), 0.15);
}

/* Template details */
.template-details {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f5f5f5;
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
}

.template-details h3 {
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.template-details p {
    margin-bottom: 0.5rem;
}

.template-details ul {
    list-style-type: none;
    margin: 0.5rem 0;
    padding-left: 0.5rem;
}

.template-details li {
    padding: 0.25rem 0;
}

.template-details .key {
    font-weight: bold;
    color: var(--primary-color);
}

/* Results section */
.results-section {
    display: none;
}

.results-section.active {
    display: block;
}

.processed-message {
    padding: 10px 15px;
    margin-bottom: 20px;
    background-color: rgba(var(--success-color-rgb), 0.1);
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
    font-weight: bold;
    border-radius: 4px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.result-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.result-item:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><circle cx="50" cy="50" fill="none" stroke="%234a6fa5" stroke-width="8" r="35" stroke-dasharray="164.93361431346415 56.97787143782138"><animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1s" values="0 50 50;360 50 50" keyTimes="0;1"></animateTransform></circle></svg>');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 50px;
    opacity: 1;
    transition: opacity 0.3s;
    z-index: 1;
}

.result-item.loaded:before {
    opacity: 0;
    pointer-events: none;
}

.result-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.result-item img {
    width: 100%;
    height: auto;
}

.result-actions {
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
}

.download-btn {
    background-color: var(--success-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    transition: background-color 0.2s;
}

.download-btn:hover {
    background-color: #1e7e34;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }
    
    .template-grid,
    .logo-grid,
    .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 480px) {
    .preview-item {
        width: 100px;
        height: 100px;
    }
}

/* Template Actions */
.template-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
    text-decoration: none;
}

/* Template Form */
.template-params {
    margin: 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

.template-params h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Additional button styles */
.secondary-btn {
    background-color: #e0e0e0;
    color: #333;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

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

.secondary-btn:disabled {
    background-color: #f0f0f0;
    color: #999;
    cursor: not-allowed;
}

/* Danger Button */
.danger-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

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

.danger-btn:disabled {
    background-color: #f2acb3;
    color: #fff;
    cursor: not-allowed;
}

/* Date picker modal styling */
.date-picker-content {
    max-width: 400px;
}

.date-picker-content .form-group {
    margin-bottom: 15px;
}

.date-picker-content label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.date-picker-content input[type="date"],
.date-picker-content input[type="time"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Date display styling */
.date-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-display span {
    flex: 1;
}

.edit-date-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    opacity: 1;
}

.edit-date-btn:hover {
    background-color: #3a5a8c;
}

/* Responsive Table Styles */
.schedule-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.schedule-table th,
.schedule-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.schedule-table th {
    background-color: #f5f5f5;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.schedule-table tr:hover {
    background-color: rgba(var(--primary-color-rgb), 0.05);
}

/* Make thumbnails responsive */
.thumbnail {
    max-width: 80px;
    max-height: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.thumbnail:hover {
    transform: scale(1.05);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .schedule-table th,
    .schedule-table td {
        padding: 8px 5px;
    }
    
    .thumbnail {
        max-width: 60px;
        max-height: 60px;
    }
    
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .action-btn {
        padding: 5px;
        font-size: 12px;
    }
    
    /* Ensure edit button is visible and sized appropriately */
    .date-display {
        gap: 5px;
    }
    
    .edit-date-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }
}

@media (max-width: 576px) {
    .schedule-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .schedule-controls input,
    .schedule-controls button {
        width: 100%;
    }
    
    .thumbnail {
        max-width: 50px;
        max-height: 50px;
    }
    
    /* Further reduce edit button size on very small screens */
    .edit-date-btn {
        width: 24px;
        height: 24px;
        min-width: 24px;
    }
} 