/* -------------------------------------------------------------
   InstaSnap - Custom CSS Stylesheet
   Modern Glassmorphism and Instagram Gradient Theme
   ------------------------------------------------------------- */

/* Reset & Base Variables */
:root {
    --bg-color: #08050e;
    --card-bg: rgba(18, 12, 28, 0.65);
    --border-light: rgba(255, 255, 255, 0.08);
    --border-active: rgba(220, 39, 67, 0.4);
    
    --text-main: #f3effa;
    --text-muted: #9c91ad;
    
    /* Instagram Gradient Colors */
    --ig-orange: #f09433;
    --ig-coral: #e6683c;
    --ig-magenta: #dc2743;
    --ig-pink: #cc2366;
    --ig-purple: #bc1888;
    --primary-grad: linear-gradient(135deg, var(--ig-orange) 0%, var(--ig-coral) 25%, var(--ig-magenta) 50%, var(--ig-pink) 75%, var(--ig-purple) 100%);
    --primary-glow: rgba(220, 39, 67, 0.4);
    
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --glass-blur: blur(20px);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-stack: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-stack);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 20px 10px;
}

/* Background Decor Circles */
.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    mix-blend-mode: screen;
}

.circle-1 {
    top: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: var(--ig-orange);
    animation: floatCircles 20s infinite alternate;
}

.circle-2 {
    bottom: -20%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: var(--ig-purple);
    animation: floatCircles 25s infinite alternate-reverse;
}

.circle-3 {
    top: 40%;
    left: 30%;
    width: 400px;
    height: 400px;
    background: var(--ig-magenta);
    opacity: 0.1;
    animation: floatCircles 18s infinite alternate;
}

@keyframes floatCircles {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(30px, 40px) scale(1.1);
    }
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 5px;
}

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

.logo-icon {
    font-size: 2.5rem;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(220, 39, 67, 0.3));
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 300;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Main Card Glassmorphism */
.main-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: var(--transition-smooth);
}

.main-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Form Input Section */
.input-section {
    width: 100%;
}

#download-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2px 6px;
    transition: var(--transition-smooth);
}

.input-wrapper:focus-within {
    border-color: var(--border-active);
    box-shadow: 0 0 15px rgba(220, 39, 67, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.06);
}

.input-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-left: 14px;
    margin-right: 8px;
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-stack);
    font-size: 1rem;
    padding: 16px 8px;
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: #6d637c;
}

/* Helper Action Buttons inside Input */
.btn-secondary-action {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-stack);
    font-weight: 500;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.btn-secondary-action:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.1);
}

#btn-clear {
    padding: 10px;
    border-radius: 50%;
    background: transparent;
    border: none;
}

#btn-clear:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--error-color);
}

/* Primary Button */
.btn-primary {
    background: var(--primary-grad);
    border: none;
    outline: none;
    color: white;
    font-family: var(--font-stack);
    font-weight: 600;
    font-size: 1.1rem;
    padding: 16px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(220, 39, 67, 0.55);
}

.btn-primary:active {
    transform: translateY(0);
}

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

/* Loading Spinner Section */
#loading-section {
    margin-top: 10px;
    animation: fadeIn 0.3s ease-out;
}

.loader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px 0;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.08);
    border-top: 4px solid var(--ig-magenta);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader-wrapper p {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 300;
}

/* Alert Boxes (Error/Info) */
.alert-box {
    margin-top: 20px;
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    animation: slideDown 0.3s ease-out;
}

.error-alert {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-icon {
    font-size: 1.3rem;
    margin-top: 2px;
}

.alert-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-content p {
    font-size: 0.85rem;
    opacity: 0.85;
    line-height: 1.4;
}

/* Preview Section */
#preview-section {
    margin-top: 25px;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-card {
    display: flex;
    flex-direction: row;
    gap: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 16px;
}

.preview-media {
    position: relative;
    width: 140px;
    height: 180px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 60%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-icon {
    font-size: 2.2rem;
    color: white;
    opacity: 0.8;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
    transition: var(--transition-smooth);
}

.preview-card:hover .play-icon {
    transform: scale(1.1);
    opacity: 1;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
}

.preview-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    padding: 4px 0;
}

.uploader-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.uploader-info i {
    font-size: 0.9rem;
}

.preview-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-main);
    margin-top: 8px;
    margin-bottom: auto;
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.btn-download-item {
    background: var(--primary-grad);
    border: none;
    outline: none;
    color: white;
    font-family: var(--font-stack);
    font-weight: 600;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(220, 39, 67, 0.25);
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-download-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(220, 39, 67, 0.45);
}

.btn-download-item.downloading {
    background: linear-gradient(90deg, #5b21b6 0%, #7c3aed 100%);
    cursor: wait;
    box-shadow: none;
}

/* History Section */
.history-section {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.history-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-text {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-stack);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.btn-text:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.06);
}

/* History List States */
#history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

#history-list::-webkit-scrollbar {
    width: 6px;
}

#history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.empty-state {
    text-align: center;
    padding: 30px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-icon {
    font-size: 2.2rem;
    color: rgba(255, 255, 255, 0.15);
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* History Items */
.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 10px 12px;
    transition: var(--transition-smooth);
    animation: fadeIn 0.3s ease-out;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
}

.history-thumb {
    width: 48px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

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

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

.history-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-actions {
    display: flex;
    gap: 6px;
}

.btn-history-action {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-history-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ig-coral);
    border-color: rgba(220, 39, 67, 0.15);
}

.btn-history-action.btn-delete:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.15);
}

/* Footer styling */
footer {
    text-align: center;
    margin-top: 10px;
}

footer p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.25);
    font-weight: 300;
}

/* Utility classes & helper animations */
.hidden {
    display: none !important;
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: 10px 5px;
    }
    
    .main-card {
        padding: 20px 15px;
        border-radius: 20px;
    }
    
    .history-section {
        padding: 16px;
        border-radius: 20px;
    }
    
    .preview-card {
        flex-direction: column;
        gap: 16px;
    }
    
    .preview-media {
        width: 100%;
        height: 220px;
    }
    
    .btn-secondary-action span {
        display: none; /* Sembunyikan teks 'Paste' pada perangkat mobile */
    }
}

/* Supported Platforms Badges */
.supported-platforms {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition-smooth);
}

.platform-badge[data-platform="instagram"]:hover {
    background: rgba(220, 39, 67, 0.1);
    border-color: rgba(220, 39, 67, 0.3);
    color: #e6683c;
}

.platform-badge[data-platform="facebook"]:hover {
    background: rgba(24, 119, 242, 0.1);
    border-color: rgba(24, 119, 242, 0.3);
    color: #1877f2;
}

.platform-badge[data-platform="tiktok"]:hover {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(254, 44, 85, 0.3);
    color: #fe2c55;
}

.platform-badge[data-platform="youtube"]:hover {
    background: rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 0, 0, 0.3);
    color: #ff0000;
}

/* Audio Download Button */
.btn-audio {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25) !important;
    margin-top: 8px;
}

.btn-audio:hover {
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45) !important;
}

/* Footer & Version Badge */
footer {
    text-align: center;
    margin-top: 40px;
    padding-bottom: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.app-version-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.app-version-badge:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.app-version-badge i {
    color: #e6683c;
}

