/* Basic Reset & Font */
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(to bottom right, #f3e8ff, #e0f2fe);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
}

#main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    min-height: 100vh;
}

/* Container Styles */
.container {
    width: 100%;
    max-width: 96rem; /* max-w-4xl */
    text-align: center;
    margin-bottom: 2rem; /* mb-8 */
}

.section-card {
    width: 100%;
    max-width: 48rem; /* max-w-2xl */
    background-color: #ffffff; /* bg-white */
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
    padding: 1.5rem; /* p-6 */
    margin-bottom: 2rem; /* mb-8 */
    border: 1px solid #c7d2fe; /* border border-indigo-200 */
    box-sizing: border-box;
}

.section-card.green-border {
    border-color: #bbf7d0; /* border border-green-200 */
}

.section-card.red-border {
    background-color: #fee2e2; /* bg-red-100 */
    border-color: #fca5a5; /* border border-red-400 */
    color: #b91c1c; /* text-red-700 */
    padding: 0.75rem 1rem; /* px-4 py-3 */
    border-radius: 0.5rem; /* rounded-lg */
    position: relative;
}

/* Typography */
h1 {
    font-size: 2.25rem; /* text-4xl */
    line-height: 2.5rem; /* sm:text-5xl */
    font-weight: 800; /* font-extrabold */
    color: #3730a3; /* text-indigo-800 */
    margin-bottom: 0.5rem; /* mb-2 */
}

p {
    font-size: 1.125rem; /* text-lg */
    line-height: 1.75rem;
    color: #4b5563; /* text-gray-600 */
}

label {
    display: block;
    color: #374151; /* text-gray-700 */
    font-size: 0.875rem; /* text-sm */
    font-weight: 600; /* font-semibold */
    margin-bottom: 0.5rem; /* mb-2 */
}

textarea, input[type="text"], select {
    width: 100%;
    padding: 0.75rem; /* p-3 */
    border: 1px solid #d1d5db; /* border border-gray-300 */
    border-radius: 0.5rem; /* rounded-lg */
    transition: all 0.2s ease-in-out; /* transition duration-200 ease-in-out */
    box-sizing: border-box;
}

textarea:focus, input[type="text"]:focus, select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5); /* focus:ring-2 focus:ring-indigo-500 */
    border-color: transparent; /* focus:border-transparent */
}

textarea {
    resize: vertical; /* resize-y */
    min-height: 100px; /* min-h-[100px] */
}

/* Buttons */
button {
    width: 100%;
    background-color: #4f46e5; /* bg-indigo-600 */
    color: #ffffff; /* text-white */
    padding: 0.75rem 1.5rem; /* py-3 px-6 */
    border-radius: 0.5rem; /* rounded-lg */
    font-weight: 700; /* font-bold */
    font-size: 1.125rem; /* text-lg */
    transition: all 0.3s ease-in-out; /* transition duration-300 ease-in-out */
    transform: scale(1); /* transform */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
    border: none;
    cursor: pointer;
}

button:hover {
    background-color: #4338ca; /* hover:bg-indigo-700 */
    transform: scale(1.05); /* hover:scale-105 */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* hover:shadow-lg */
}

button:disabled {
    opacity: 0.5; /* disabled:opacity-50 */
    cursor: not-allowed; /* disabled:cursor-not-allowed */
    transform: scale(1);
    box-shadow: none;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner svg {
    animation: spin 1s linear infinite; /* animate-spin */
    -webkit-animation: spin 1s linear infinite;
    margin-right: 0.75rem; /* mr-3 */
    height: 1.25rem; /* h-5 */
    width: 1.25rem; /* w-5 */
    color: #ffffff; /* text-white */
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Image Grid */
.image-grid {
    width: 100%;
    max-width: 64rem; /* max-w-4xl */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* sm:grid-cols-2 lg:grid-cols-3 */
    gap: 1.5rem; /* gap-6 */
}

.image-card {
    background-color: #ffffff; /* bg-white */
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
    overflow: hidden;
    border: 1px solid #e5e7eb; /* border border-gray-200 */
    transition: all 0.3s ease-in-out; /* transition duration-300 ease-in-out */
    transform: scale(1); /* transform */
}

.image-card:hover {
    transform: scale(1.05); /* hover:scale-105 */
}

.image-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem; /* p-3 */
    background-color: #f9fafb; /* bg-gray-50 */
    border-bottom: 1px solid #e5e7eb; /* border-b border-gray-200 */
}

.image-card-header h3 {
    font-size: 1.125rem; /* text-lg */
    font-weight: 600; /* font-semibold */
    color: #374151; /* text-gray-800 */
    margin: 0;
}

.image-card-actions {
    display: flex;
    gap: 0.5rem; /* gap-2 */
}

.image-card-actions button {
    width: auto; /* Override full width */
    padding: 0.5rem; /* p-2 */
    border-radius: 9999px; /* rounded-full */
    transition: all 0.2s ease-in-out;
    box-shadow: none; /* Remove button shadow */
}

.image-card-actions button.download-btn {
    background-color: #e0e7ff; /* bg-indigo-100 */
    color: #4f46e5; /* text-indigo-600 */
}

.image-card-actions button.download-btn:hover {
    background-color: #c7d2fe; /* hover:bg-indigo-200 */
    transform: scale(1.05);
}

.image-card-actions button.edit-btn {
    background-color: #dcfce7; /* bg-green-100 */
    color: #16a34a; /* text-green-600 */
}

.image-card-actions button.edit-btn:hover {
    background-color: #bbf7d0; /* hover:bg-green-200 */
    transform: scale(1.05);
}

.image-card-actions button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5); /* focus:ring-2 focus:ring-indigo-500 */
    border-color: transparent;
}

.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 16rem; /* h-64 */
    background-color: #f3f4f6; /* bg-gray-100 */
    color: #ef4444; /* text-red-500 */
    text-align: center;
    padding: 1rem;
}

.image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* For 1:1 aspect ratio */
    overflow: hidden;
}

.image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* object-cover */
    border-bottom-left-radius: 0.5rem; /* rounded-b-lg */
    border-bottom-right-radius: 0.5rem; /* rounded-b-lg */
}

/* Edit Mode Styles */
.edit-mode-container {
    width: 100%;
    max-width: 48rem; /* max-w-2xl */
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #c7d2fe;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.edit-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.edit-header-row h1 {
    flex-grow: 1; /* Allow title to take available space */
    text-align: center;
    margin: 0; /* Reset margin from h1 style */
    font-size: 1.5rem; /* Smaller for header */
    line-height: 1.5rem;
}

.edit-header-row .icon-button {
    width: 32px; /* 32x32px */
    height: 32px; /* 32x32px */
    padding: 0; /* Remove padding */
    border-radius: 50%; /* Make it round */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease-in-out;
    box-shadow: none; /* Remove button shadow */
}

.edit-header-row .icon-button svg {
    width: 20px; /* Adjust SVG size if needed within 32x32 button */
    height: 20px;
}

.edit-header-row .icon-button.back-btn {
    background-color: #e5e7eb; /* bg-gray-200 */
    color: #4b5563; /* text-gray-700 */
}
.edit-header-row .icon-button.back-btn:hover {
    background-color: #d1d5db; /* hover:bg-gray-300 */
}

.edit-header-row .icon-button.download-btn {
    background-color: #e0e7ff; /* bg-indigo-100 */
    color: #4f46e5; /* text-indigo-600 */
}
.edit-header-row .icon-button.download-btn:hover {
    background-color: #c7d2fe; /* hover:bg-indigo-200 */
}

.edit-image-section {
    width: 100%;
    max-width: 32rem;
    border: 5px solid black;
    border-radius: 0; /* No rounded corners */
    overflow: visible;
    padding: 0;
    margin-bottom: 1rem;
    margin-top: 0; /* Remove extra white space above image */
    box-sizing: border-box;
}

.edit-image-section .image-wrapper {
    width: 100%;
    height: auto;
    position: relative;
    overflow: visible;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: none;
}

.edit-image-section .image-wrapper img {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 500px;
    object-fit: contain; /* Show full image, not cropped */
    border-radius: 0;
    padding: 0;
    margin: 0 auto;
    box-sizing: border-box;
    background: none;
}

.edit-controls-section {
    width: 100%;
    max-width: 32rem; /* Match image section width */
    background-color: #f9fafb; /* bg-gray-50 */
    border-radius: 0.75rem; /* rounded-xl */
    padding: 1rem; /* p-4 */
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06); /* shadow-inner */
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Space between elements */
}

.edit-loading-indicator {
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.edit-loading-indicator svg {
    animation: spin 1s linear infinite;
    height: 1.25rem;
    width: 1.25rem;
    color: #6366f1; /* text-indigo-500 */
}

.edit-loading-indicator span {
    margin-left: 0.5rem;
    color: #4b5563; /* text-gray-600 */
}

.edit-input-area {
    width: 100%;
    display: flex;
    gap: 0.5rem; /* gap-2 */
}

.edit-input-area textarea {
    flex-grow: 1; /* flex-grow */
    resize: none;
    min-height: 2.5rem; /* Adjust as needed */
}

.edit-input-area button {
    width: auto; /* Override full width */
    padding: 0.75rem 1.5rem; /* py-3 px-6 */
    font-size: 1.125rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Responsive adjustments */
@media (min-width: 640px) { /* sm: */
    body {
        padding: 1.5rem; /* sm:p-6 */
    }
    h1 {
        font-size: 3rem; /* sm:text-5xl */
    }
    .image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* sm:grid-cols-2 */
    }
    .section-card.red-border {
        display: inline-block; /* sm:inline */
    }
}

@media (min-width: 1024px) { /* lg: */
    .image-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)); /* lg:grid-cols-3 */
    }
}

/* Status Bar and Modals */
.bg-gray-100 {
    background-color: #f9fafb !important;
}
.text-gray-800 {
    color: #374151 !important;
}
.font-sans {
    font-family: 'Inter', sans-serif !important;
}

/* Status Bar */
.status-bar {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    width: auto;
    min-width: 200px;
    max-width: 300px;
    z-index: 2000;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    background: #f3f4f6;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    color: #4b5563;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.status-indicator {
    margin-right: 0.5rem;
}
.status-text {
    padding-left: 2.5rem;
    padding-right: 1rem;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    width: 350px;
    text-align: center;
}
.modal-content h2 {
    margin-bottom: 1rem;
    color: #3730a3;
}
.modal-content p {
    margin-bottom: 1rem;
    color: #4b5563;
}
.button-primary {
    width: 100%;
    background: #4f46e5;
    color: #fff;
    padding: 0.75rem 0;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
}
.button-primary:hover {
    background: #4338ca;
}
.text-red-500 {
    color: #b91c1c !important;
}
