/* Google Sans Font */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap');

/* Doraemon Color Palette */
:root {
    --doraemon-blue: #01a0e9;
    --doraemon-blue-dark: #0085c7;
    --doraemon-red: #fd000f;
    --doraemon-yellow: #ffcb00;
    --doraemon-white: #ffffff;
}

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

body {
    font-family: "Google Sans", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    background: linear-gradient(135deg, #e8f4fc 0%, #fef9e7 50%, #fee8e8 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--doraemon-white);
    color: #333;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    border-right: 3px solid var(--doraemon-blue);
    box-shadow: 4px 0 20px rgba(1, 160, 233, 0.15);
}

.sidebar-header {
    padding: 28px 24px;
    background: linear-gradient(135deg, var(--doraemon-blue) 0%, var(--doraemon-blue-dark) 100%);
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.2));
    transition: transform 0.3s;
}

.sidebar-logo:hover {
    transform: scale(1.1) rotate(-5deg);
}

.sidebar-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--doraemon-white);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: #555;
    text-decoration: none;
    border-radius: 50px;
    margin-bottom: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    border: 2px solid transparent;
}

.nav-item:hover {
    background: linear-gradient(135deg, #e8f7fd 0%, #f0faff 100%);
    color: var(--doraemon-blue);
    transform: translateX(6px);
    border-color: var(--doraemon-blue);
}

.nav-item.active {
    background: var(--doraemon-blue);
    color: var(--doraemon-white);
    box-shadow: 0 4px 15px rgba(1, 160, 233, 0.4);
    transform: translateX(6px);
}

.nav-item.active:hover {
    background: var(--doraemon-blue-dark);
    border-color: transparent;
}

.nav-item svg,
.nav-item i {
    width: 22px;
    height: 22px;
}

.sidebar-footer {
    padding: 18px 24px;
    font-size: 0.8rem;
    color: #888;
    border-top: 2px dashed var(--doraemon-yellow);
    background: #fffef5;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 40px;
    min-height: 100vh;
}

/* Tool Sections */
.tool-section {
    display: none;
    max-width: 900px;
    margin: 0 auto;
}

.tool-section.active {
    display: block;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-header {
    margin-bottom: 32px;
    text-align: center;
}

.tool-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--doraemon-blue);
    position: relative;
    display: inline-block;
}

.tool-header h2::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--doraemon-red);
    border-radius: 2px;
}

.tool-header p {
    color: #666;
    font-size: 1.05rem;
    margin-top: 12px;
}

.tool-content {
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 8px 30px rgba(1, 160, 233, 0.12);
    border: 2px solid #e8f4fc;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
}

.input-group input {
    flex: 1;
    padding: 16px 22px;
    border: 3px solid #e1e5eb;
    border-radius: 50px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
    background: #fafbfc;
}

.input-group input:focus {
    border-color: var(--doraemon-blue);
    background: white;
    box-shadow: 0 0 0 4px rgba(1, 160, 233, 0.1);
}

.input-group input::placeholder {
    color: #aaa;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn i,
.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--doraemon-blue) 0%, var(--doraemon-blue-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(1, 160, 233, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(1, 160, 233, 0.4);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: white;
    color: var(--doraemon-blue);
    border: 2px solid var(--doraemon-blue);
}

.btn-secondary:hover {
    background: var(--doraemon-blue);
    color: white;
    transform: translateY(-2px);
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.15rem;
    margin-top: 24px;
}

.button-group {
    display: flex;
    gap: 14px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Video Info */
.video-info {
    display: flex;
    gap: 24px;
    padding: 24px;
    background: linear-gradient(135deg, #f8fcfe 0%, #fefbf5 100%);
    border-radius: 20px;
    margin-bottom: 28px;
    border: 2px solid #e8f4fc;
}

.video-info img {
    width: 220px;
    min-width: 220px;
    height: 124px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.video-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.video-details h3 {
    font-size: 1.15rem;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.video-details p {
    color: #666;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Download Options */
.download-options h4 {
    margin-bottom: 18px;
    font-weight: 600;
    color: #444;
    font-size: 1.1rem;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 16px;
    background: white;
    border: 3px solid #e8ecf0;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.option-card:hover {
    border-color: var(--doraemon-blue);
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(1, 160, 233, 0.2);
}

.option-card:has(input:checked) {
    border-color: var(--doraemon-blue);
    background: linear-gradient(135deg, #e8f7fd 0%, #f0faff 100%);
    box-shadow: 0 4px 15px rgba(1, 160, 233, 0.2);
}

.option-card input {
    display: none;
}

.option-card i,
.option-card svg {
    width: 32px;
    height: 32px;
    color: #888;
    transition: all 0.3s;
}

.option-card:hover i,
.option-card:hover svg {
    color: var(--doraemon-blue);
    transform: scale(1.1);
}

.option-card:has(input:checked) i,
.option-card:has(input:checked) svg {
    color: var(--doraemon-blue);
}

.option-card span {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.option-card:has(input:checked) span {
    color: var(--doraemon-blue);
}

.sub-option {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.sub-option label {
    font-weight: 500;
    min-width: 60px;
}

.sub-option select {
    padding: 10px 16px;
    border: 2px solid #e1e5eb;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
}

/* Upload Area */
.upload-area {
    border: 3px dashed var(--doraemon-blue);
    border-radius: 24px;
    padding: 70px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: linear-gradient(135deg, #f8fcfe 0%, #fefefe 100%);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(1, 160, 233, 0.05) 0%, rgba(255, 203, 0, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.upload-area:hover {
    border-color: var(--doraemon-blue);
    transform: scale(1.01);
    box-shadow: 0 10px 40px rgba(1, 160, 233, 0.15);
}

.upload-area:hover::before {
    opacity: 1;
}

.upload-area svg,
.upload-area i {
    width: 64px;
    height: 64px;
    color: var(--doraemon-blue);
    margin-bottom: 20px;
    transition: transform 0.3s;
}

.upload-area:hover svg,
.upload-area:hover i {
    transform: scale(1.1) translateY(-5px);
}

.upload-area p {
    color: #555;
    font-size: 1.05rem;
    font-weight: 500;
}

/* Preview Section */
.preview-section {
    margin-top: 24px;
}

.image-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.image-box h4 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 12px;
}

.image-box img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    background: #f0f0f0;
    border-radius: 8px;
}

/* Progress */
.progress-container {
    margin: 28px 0;
}

.progress-bar {
    height: 12px;
    background: #e8ecf0;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--doraemon-blue), var(--doraemon-blue-dark), var(--doraemon-blue));
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.3s;
    border-radius: 50px;
    animation: shimmer 2s infinite linear;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-container p {
    text-align: center;
    margin-top: 12px;
    color: #555;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Loading */
.loading {
    text-align: center;
    padding: 50px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e8f4fc;
    border-top-color: var(--doraemon-blue);
    border-right-color: var(--doraemon-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

/* Error Message - Doraemon Red */
.error-message {
    padding: 18px 24px;
    background: linear-gradient(135deg, #fff5f5 0%, #fff0f0 100%);
    border: 2px solid var(--doraemon-red);
    color: var(--doraemon-red);
    border-radius: 16px;
    margin-top: 20px;
    font-weight: 500;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Success Message - Doraemon Yellow */
.success-message {
    padding: 18px 24px;
    background: linear-gradient(135deg, #fffef5 0%, #fffbeb 100%);
    border: 2px solid var(--doraemon-yellow);
    color: #b8860b;
    border-radius: 16px;
    margin-top: 20px;
    font-weight: 500;
    animation: pop 0.4s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Editor Section */
.editor-section {
    margin-top: 24px;
}

.canvas-container {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.canvas-container canvas {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#selectionCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

.editor-controls {
    background: #f8f9fb;
    padding: 20px;
    border-radius: 12px;
}

.editor-controls .hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.control-group label {
    font-weight: 500;
}

.control-group select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header {
        padding: 16px;
        justify-content: center;
    }

    .sidebar-header h1,
    .nav-item span,
    .sidebar-footer {
        display: none;
    }

    .sidebar-logo {
        width: 38px;
        height: 38px;
    }

    .nav-item {
        justify-content: center;
        padding: 14px;
        border-radius: 50%;
        margin: 4px 8px;
    }

    .nav-item.active {
        transform: none;
    }

    .main-content {
        margin-left: 70px;
        padding: 20px;
    }

    .tool-header h2 {
        font-size: 1.5rem;
    }

    .tool-content {
        padding: 24px;
        border-radius: 20px;
    }

    .option-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .image-compare {
        grid-template-columns: 1fr;
    }

    .video-info {
        flex-direction: column;
    }

    .video-info img {
        width: 100%;
        height: auto;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group input,
    .input-group .btn {
        width: 100%;
    }
}

/* OGP Preview Styles */
.ogp-result {
    margin-top: 28px;
    max-width: 100%;
    overflow: hidden;
}

.ogp-previews {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 32px;
    max-width: 100%;
    overflow: hidden;
}

.preview-card {
    background: #f8f9fb;
    border-radius: 16px;
    padding: 20px;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.preview-card h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 16px;
    font-weight: 600;
}

.preview-card h4 svg,
.preview-card h4 i {
    width: 18px;
    height: 18px;
}

.social-preview {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e1e5eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    width: 100%;
    max-width: 100%;
}

.social-preview .preview-image-container {
    width: 100%;
    max-height: 200px;
    background: #f0f2f5;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-preview .preview-image-container img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
    display: block;
}

.social-preview .preview-content {
    padding: 12px 16px;
}

.social-preview .preview-domain {
    font-size: 0.75rem;
    color: #65676b;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.social-preview .preview-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1c1e21;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.social-preview .preview-description {
    font-size: 0.85rem;
    color: #65676b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Twitter large image card */
.twitter-preview.large-image .preview-image-container {
    max-height: 250px;
}

.twitter-preview.large-image .preview-image-container img {
    max-height: 250px;
}

/* OGP Data Table */
.ogp-data-section {
    background: #f8f9fb;
    border-radius: 16px;
    padding: 20px;
}

.ogp-data-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 16px;
    font-weight: 600;
}

.ogp-data-section h4 svg,
.ogp-data-section h4 i {
    width: 18px;
    height: 18px;
}

.ogp-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

.ogp-table th {
    background: #f0f2f5;
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
}

.ogp-table tr:last-child td {
    border-bottom: none;
}

.ogp-table .property-label {
    font-weight: 500;
    color: #333;
    width: 160px;
    font-family: monospace;
    font-size: 0.9rem;
}

.ogp-table .property-value {
    color: #555;
    word-break: break-all;
}

.ogp-table .property-value a {
    color: var(--doraemon-blue);
    text-decoration: none;
}

.ogp-table .property-value a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .ogp-previews {
        grid-template-columns: 1fr;
    }

    .ogp-table .property-label {
        width: 100px;
    }
}

/* WebP Converter Styles */
.upload-area .upload-hint {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-top: 8px;
}

.webp-settings {
    background: #f8f9fb;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.settings-row label {
    font-weight: 500;
    min-width: 60px;
}

.settings-row input[type="range"] {
    flex: 1;
    max-width: 300px;
    height: 8px;
    -webkit-appearance: none;
    background: #e1e5eb;
    border-radius: 4px;
    outline: none;
}

.settings-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--doraemon-blue);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(1, 160, 233, 0.3);
}

.settings-row span {
    font-weight: 600;
    color: var(--doraemon-blue);
    min-width: 50px;
}

.webp-preview {
    margin-top: 24px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.preview-header h4 {
    font-size: 1.1rem;
    color: #333;
}

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

.image-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f8f9fb;
    border-radius: 12px;
    padding: 12px 16px;
    border: 2px solid #e8ecf0;
    transition: all 0.2s;
}

.image-item:hover {
    border-color: var(--doraemon-blue);
    box-shadow: 0 2px 8px rgba(1, 160, 233, 0.1);
}

.image-thumb {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #e1e5eb;
    flex-shrink: 0;
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-info {
    flex: 1;
    min-width: 0;
}

.image-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-sizes {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #666;
}

.image-sizes i,
.image-sizes svg {
    width: 14px;
    height: 14px;
    color: #999;
}

.savings-positive {
    color: #22c55e;
    font-weight: 600;
}

.savings-negative {
    color: var(--doraemon-red);
    font-weight: 600;
}

.image-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.btn-small i,
.btn-small svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-actions {
        width: 100%;
    }

    .preview-actions .btn {
        flex: 1;
    }

    .image-item {
        flex-wrap: wrap;
    }

    .image-info {
        flex: 1 1 calc(100% - 76px);
    }

    .image-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
