/* InstaCut - Modern Luxury Web Styling */
:root {
    --bg-primary: #0a0d14;
    --bg-surface: #121826;
    --bg-card: rgba(24, 32, 50, 0.7);
    --bg-card-hover: rgba(30, 41, 64, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.2);
    
    --ig-gradient: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
    --ig-gradient-subtle: linear-gradient(135deg, rgba(131, 58, 180, 0.2), rgba(253, 29, 29, 0.2), rgba(252, 176, 69, 0.2));
    --primary-color: #e1306c;
    --accent-orange: #fd5949;
    --accent-yellow: #fccc63;
    --accent-purple: #833ab4;
    --accent-blue: #38bdf8;
    --accent-green: #10b981;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(225, 48, 108, 0.25);
    
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(131, 58, 180, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 75%, rgba(253, 29, 29, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(252, 176, 69, 0.05) 0%, transparent 50%);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.site-header {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    background: rgba(10, 13, 20, 0.7);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--ig-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.logo-text span {
    background: var(--ig-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-tg {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 8px 16px;
    border-radius: 100px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s ease;
}

.btn-tg:hover {
    background: #38bdf8;
    color: #0f172a;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 60px 0 30px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(225, 48, 108, 0.12);
    border: 1px solid rgba(225, 48, 108, 0.3);
    color: #ff5b94;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: 0.3px;
}

.hero h1 {
    font-size: clamp(32px, 5vw, 54px);
    font-weight: 900;
    line-height: 1.15;
    margin-bottom: 18px;
    letter-spacing: -1px;
}

.hero h1 .gradient-text {
    background: var(--ig-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: clamp(16px, 2vw, 19px);
    color: var(--text-secondary);
    max-width: 650px;
    margin: 0 auto 30px;
}

/* Main Workspace */
.app-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-bottom: 60px;
}

@media (min-width: 992px) {
    .app-workspace {
        grid-template-columns: 420px 1fr;
        align-items: start;
    }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Controls */
.control-group {
    margin-bottom: 24px;
}

.control-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.control-label span.badge-small {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--accent-yellow);
}

.rows-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.row-option {
    position: relative;
}

.row-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.row-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.row-option label .row-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.row-option label .row-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.row-option input[type="radio"]:checked + label {
    background: var(--ig-gradient);
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(225, 48, 108, 0.4);
}

.row-option input[type="radio"]:checked + label .row-count,
.row-option input[type="radio"]:checked + label .row-sub {
    color: white;
}

/* Upload Dropzone */
.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    position: relative;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary-color);
    background: rgba(225, 48, 108, 0.06);
    box-shadow: 0 0 25px rgba(225, 48, 108, 0.2);
}

.dropzone-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--ig-gradient-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff5b94;
}

.dropzone-icon svg {
    width: 28px;
    height: 28px;
}

.dropzone h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.dropzone p {
    font-size: 13px;
    color: var(--text-muted);
}

.dropzone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Process Button */
.btn-process {
    width: 100%;
    padding: 16px;
    background: var(--ig-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(225, 48, 108, 0.35);
    transition: all 0.3s ease;
}

.btn-process:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(225, 48, 108, 0.5);
}

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

/* Preview Canvas / Area */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-container {
    background: #000;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 16px;
    min-height: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.preview-placeholder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.grid-viewport {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 12px 40px rgba(0,0,0,0.8);
    border-radius: 8px;
    overflow: hidden;
    background: #080b11;
}

/* The visual Instagram 3-column Grid */
.instagram-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    background: #000;
    border: 3px solid #000;
    width: 100%;
}

.grid-tile {
    position: relative;
    aspect-ratio: 3 / 4;
    background: #182032;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.grid-tile:hover {
    transform: scale(0.98);
    filter: brightness(1.1);
}

.grid-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tile-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
}

.tile-badge.first-post {
    background: var(--ig-gradient);
    border-color: #fff;
    box-shadow: 0 0 10px rgba(253, 29, 29, 0.6);
}

.tile-overlay-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    padding: 12px 8px 6px;
    font-size: 11px;
    color: #cbd5e1;
    text-align: center;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.grid-tile:hover .tile-overlay-info {
    opacity: 1;
}

/* Results Actions */
.results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.btn-download-zip {
    flex: 1;
    min-width: 220px;
    padding: 14px 24px;
    background: var(--accent-green);
    color: #062b1e;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-download-zip:hover {
    background: #34d399;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.45);
}

/* Step-by-step posting instruction */
.posting-guide {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
}

.posting-guide h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-yellow);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.posting-guide ol {
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 13.5px;
}

.posting-guide ol li {
    margin-bottom: 8px;
}

.posting-guide ol li strong {
    color: var(--text-primary);
}

/* Telegram Promo Card */
.tg-card {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(131, 58, 180, 0.1));
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
}

@media (min-width: 768px) {
    .tg-card {
        flex-direction: row;
        text-align: left;
        justify-content: space-between;
    }
}

.tg-card-content h3 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #38bdf8;
}

.tg-card-content p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 550px;
}

/* Footer */
.site-footer {
    margin-top: auto;
    padding: 32px 0;
    border-top: 1px solid var(--border-color);
    background: rgba(10, 13, 20, 0.9);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-footer a:hover {
    color: var(--primary-color);
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

.hidden {
    display: none !important;
}
