:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-bg: #1f2937;
    --dark-card: #374151;
    --dark-text: #f9fafb;
    --light-bg: #f9fafb;
    --light-card: #ffffff;
    --light-text: #1f2937;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--light-bg) 0%, #e0f2fe 100%);
    color: var(--light-text);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.dark-mode {
    background: linear-gradient(135deg, var(--dark-bg) 0%, #1e3a8a 100%);
    color: var(--dark-text);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

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

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo {
    height: 40px;
    margin-right: 15px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.upload-section, .editor-section, .result-section, .features-section {
    background-color: var(--light-card);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 20px;
    transition: var(--transition);
}

.dark-mode .upload-section,
.dark-mode .editor-section,
.dark-mode .result-section,
.dark-mode .features-section {
    background-color: var(--dark-card);
}

.upload-container {
    margin-bottom: 20px;
}

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: var(--border-radius);
    padding: 40px 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.05);
}

.dark-mode .upload-area {
    border-color: #4b5563;
}

.dark-mode .upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1);
}

.upload-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.formats {
    display: block;
    margin-top: 10px;
    font-size: 14px;
    color: #64748b;
}

.dark-mode .formats {
    color: #9ca3af;
}

.file-input {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.editor-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 992px) {
    .editor-section {
        grid-template-columns: 3fr 2fr;
    }
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.cropper-container {
    width: 100%;
    height: 400px;
    background-color: #f1f5f9;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
}

.dark-mode .cropper-container {
    background-color: #334155;
}

.img-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.img-container img {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.image-details {
    margin-top: 20px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.detail-item {
    background-color: rgba(59, 130, 246, 0.05);
    padding: 10px 15px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.dark-mode .detail-item {
    background-color: rgba(59, 130, 246, 0.1);
}

.detail-label {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 5px;
}

.dark-mode .detail-label {
    color: #9ca3af;
}

.detail-value {
    font-weight: 600;
    font-size: 14px;
}

.editing-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editing-options h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.option-group {
    margin-bottom: 15px;
}

.option-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #64748b;
}

.dark-mode .option-group label {
    color: #9ca3af;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: 12px 15px;
    font-size: 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    background-color: var(--light-card);
    color: var(--light-text);
    cursor: pointer;
    transition: var(--transition);
}

.dark-mode .custom-select select {
    background-color: #374151;
    border-color: #4b5563;
    color: var(--dark-text);
}

.custom-select select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.select-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #64748b;
    transition: var(--transition);
}

.dark-mode .select-arrow {
    color: #9ca3af;
}

.crop-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.control-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--light-text);
    background-color: #e2e8f0;
}

.dark-mode .control-btn {
    color: var(--dark-text);
    background-color: #4b5563;
}

.control-btn:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

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

.size-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    padding: 0 10px;
    flex: 1;
    min-width: 100px;
}

.dark-mode .input-group {
    border-color: #4b5563;
}

.input-group input {
    border: none;
    padding: 10px 0;
    width: 100%;
    background: none;
    color: var(--light-text);
    outline: none;
}

.dark-mode .input-group input {
    color: var(--dark-text);
}

.input-group span {
    color: #64748b;
    font-size: 14px;
}

.dark-mode .input-group span {
    color: #9ca3af;
}

.size-separator {
    font-size: 18px;
    color: #64748b;
}

.dark-mode .size-separator {
    color: #9ca3af;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.dark-mode .icon-button {
    color: #9ca3af;
}

.icon-button:hover {
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1);
    transform: scale(1.1);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: #cbd5e1;
    border-radius: 5px;
    outline: none;
}

.dark-mode input[type="range"] {
    background: #4b5563;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.action-btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    background-color: #e2e8f0;
    color: var(--light-text);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.dark-mode .action-btn {
    background-color: #4b5563;
    color: var(--dark-text);
}

.action-btn:hover:not(:disabled) {
    background-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.dark-mode .action-btn:hover:not(:disabled) {
    background-color: #6b7280;
}

.action-btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.action-btn.primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

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

.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.result-container h3 {
    font-size: 18px;
    color: var(--primary-color);
}

.result-image-container {
    max-width: 100%;
    max-height: 400px;
    overflow: auto;
    background-color: #f1f5f9;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.dark-mode .result-image-container {
    background-color: #334155;
}

.result-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.result-details {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.feature-heading {
    text-align: center;
    margin-bottom: 30px;
}

.feature-heading h2 {
    font-size: 28px;
    margin-bottom: 10px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.feature-heading p {
    color: #64748b;
    font-size: 16px;
}

.dark-mode .feature-heading p {
    color: #9ca3af;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.feature-item {
    padding: 20px;
    background-color: rgba(59, 130, 246, 0.05);
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.dark-mode .feature-item {
    background-color: rgba(59, 130, 246, 0.1);
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--box-shadow);
}

.feature-icon {
    font-size: 36px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.feature-title {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 10px;
}

.feature-description {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.dark-mode .feature-description {
    color: #9ca3af;
}

/* CropperJS Styles */
.cropper-container {
    direction: ltr;
    font-size: 0;
    line-height: 0;
    position: relative;
    touch-action: none;
    user-select: none;
}

.cropper-wrap-box {
    overflow: hidden;
}

.cropper-drag-box {
    background-color: #fff;
    opacity: 0;
    position: absolute;
}

.cropper-view-box {
    display: block;
    height: 100%;
    outline: 1px solid var(--primary-color);
    outline-color: rgba(59, 130, 246, 0.75);
    overflow: hidden;
    width: 100%;
}

.cropper-dashed {
    border: 0 dashed #eee;
    display: block;
    opacity: 0.5;
    position: absolute;
}

.cropper-dashed.dashed-h {
    border-bottom-width: 1px;
    border-top-width: 1px;
    height: calc(100% / 3);
    left: 0;
    top: calc(100% / 3);
    width: 100%;
}

.cropper-dashed.dashed-v {
    border-left-width: 1px;
    border-right-width: 1px;
    height: 100%;
    left: calc(100% / 3);
    top: 0;
    width: calc(100% / 3);
}

.cropper-center {
    display: block;
    height: 0;
    left: 50%;
    opacity: 0.75;
    position: absolute;
    top: 50%;
    width: 0;
}

.cropper-center::before,
.cropper-center::after {
    background-color: #eee;
    content: ' ';
    display: block;
    position: absolute;
}

.cropper-center::before {
    height: 1px;
    left: -3px;
    top: 0;
    width: 7px;
}

.cropper-center::after {
    height: 7px;
    left: 0;
    top: -3px;
    width: 1px;
}

.cropper-face,
.cropper-line,
.cropper-point {
    display: block;
    height: 100%;
    opacity: 0.1;
    position: absolute;
    width: 100%;
}

.cropper-face {
    background-color: #fff;
    left: 0;
    top: 0;
}

.cropper-line {
    background-color: var(--primary-color);
}

.cropper-line.line-e {
    cursor: e-resize;
    right: -3px;
    top: 0;
    width: 5px;
}

.cropper-line.line-n {
    cursor: n-resize;
    height: 5px;
    left: 0;
    top: -3px;
}

.cropper-line.line-w {
    cursor: w-resize;
    left: -3px;
    top: 0;
    width: 5px;
}

.cropper-line.line-s {
    bottom: -3px;
    cursor: s-resize;
    height: 5px;
    left: 0;
}

.cropper-point {
    background-color: var(--primary-color);
    height: 5px;
    opacity: 0.75;
    width: 5px;
}

.cropper-point.point-e {
    cursor: e-resize;
    margin-top: -3px;
    right: -3px;
    top: 50%;
}

.cropper-point.point-n {
    cursor: n-resize;
    left: 50%;
    margin-left: -3px;
    top: -3px;
}

.cropper-point.point-w {
    cursor: w-resize;
    left: -3px;
    margin-top: -3px;
    top: 50%;
}

.cropper-point.point-s {
    bottom: -3px;
    cursor: s-resize;
    left: 50%;
    margin-left: -3px;
}

.cropper-point.point-ne {
    cursor: ne-resize;
    right: -3px;
    top: -3px;
}

.cropper-point.point-nw {
    cursor: nw-resize;
    left: -3px;
    top: -3px;
}

.cropper-point.point-sw {
    bottom: -3px;
    cursor: sw-resize;
    left: -3px;
}

.cropper-point.point-se {
    bottom: -3px;
    cursor: se-resize;
    height: 20px;
    opacity: 1;
    right: -3px;
    width: 20px;
}

.cropper-point.point-se::before {
    background-color: var(--primary-color);
    bottom: -50%;
    content: ' ';
    display: block;
    height: 200%;
    opacity: 0;
    position: absolute;
    right: -50%;
    width: 200%;
}

.cropper-invisible {
    opacity: 0;
}

.cropper-bg {
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
}

.cropper-hide {
    display: block;
    height: 0;
    position: absolute;
    width: 0;
}

.cropper-hidden {
    display: none !important;
}

.cropper-move {
    cursor: move;
}

.cropper-crop {
    cursor: crosshair;
}

.cropper-disabled .cropper-drag-box,
.cropper-disabled .cropper-face,
.cropper-disabled .cropper-line,
.cropper-disabled .cropper-point {
    cursor: not-allowed;
}

/* Footer styles */
.footer {
    margin-top: 40px;
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    background-color: var(--light-card);
    transition: var(--transition);
}

.dark-mode .footer {
    background-color: var(--dark-card);
    border-top-color: #4b5563;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer p {
    margin: 10px 0;
    font-size: 14px;
    color: #64748b;
}

.dark-mode .footer p {
    color: #9ca3af;
}

.footer-links {
    line-height: 1.6;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.dmca-badge {
    display: inline-block;
    margin-bottom: 10px;
}

/* Toast styles */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    color: white;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 350px;
    animation: slideIn 0.3s, fadeOut 0.5s 2.5s forwards;
    pointer-events: none;
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.toast.success { background-color: var(--success-color); }
.toast.error { background-color: var(--danger-color); }
.toast.warning { background-color: var(--warning-color); }
.toast.info { background-color: var(--info-color); }

.toast i {
    margin-right: 10px;
    font-size: 18px;
}

/* Theme toggle button */
#theme-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--light-text);
    background-color: #e2e8f0;
}

.dark-mode #theme-btn {
    color: var(--dark-text);
    background-color: #4b5563;
}

#theme-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: rotate(30deg);
}

/* Utility classes */
.hidden {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .size-inputs {
        flex-direction: column;
    }
    
    .size-separator {
        display: none;
    }
    
    .crop-controls {
        justify-content: center;
    }
    
    .details-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Additional responsive styles */
@media (max-width: 640px) {
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .footer-links a {
        margin: 0;
    }
}
