/* ==================== CROCKY Content Factory Styles ==================== */
/* iOS-inspired Design System */

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

:root {
    --ios-blue: #007AFF;
    --ios-blue-light: #5AC8FA;
    --ios-blue-dark: #0051D5;
    --ios-green: #34C759;
    --ios-red: #FF3B30;
    --ios-orange: #FF9500;
    --ios-yellow: #FFCC00;
    --ios-purple: #AF52DE;
    --ios-pink: #FF2D55;
    --ios-gray: #8E8E93;
    --ios-gray-light: #E5E5EA;
    --ios-gray-dark: #3A3A3C;
    --ios-bg: #F2F2F7;
    --ios-card: #FFFFFF;
    --ios-shadow: rgba(0, 0, 0, 0.1);
    --ios-shadow-hover: rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: var(--ios-gray-dark);
    line-height: 1.6;
}

html {
    scroll-behavior: smooth;
}

/* ==================== Auth Screen ==================== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--ios-card);
    border-radius: 24px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 10px 40px var(--ios-shadow);
    animation: slideUp 0.5s ease-out;
}

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

.auth-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-blue-light) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 800;
    color: white;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.3);
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    color: var(--ios-gray-dark);
}

.auth-subtitle {
    text-align: center;
    color: var(--ios-gray);
    margin-bottom: 30px;
    font-size: 15px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--ios-gray);
    font-size: 14px;
}

.auth-switch a {
    color: var(--ios-blue);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ==================== Form Elements ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 15px;
    font-weight: 500;
    color: var(--ios-gray-dark);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--ios-gray-light);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--ios-bg);
}

.form-control:focus {
    outline: none;
    border-color: var(--ios-blue);
    background: white;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8E93' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* ==================== Buttons ==================== */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-blue-light) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

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

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

.btn-secondary {
    background: var(--ios-gray-light);
    color: var(--ios-gray-dark);
}

.btn-secondary:hover {
    background: #D1D1D6;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 16px;
}

.btn-edit {
    background: var(--ios-blue);
    color: white;
    flex: 1;
}

.btn-download {
    background: var(--ios-green);
    color: white;
}

.btn-delete {
    background: var(--ios-red);
    color: white;
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* ==================== Main App Layout ==================== */
.app-container {
    display: none;
}

.app-container.active {
    display: flex;
    height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: 280px;
    background: var(--ios-card);
    box-shadow: 2px 0 20px var(--ios-shadow);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid var(--ios-gray-light);
}

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

.sidebar-logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-blue-light) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ios-gray-dark);
}

.sidebar-brand p {
    font-size: 12px;
    color: var(--ios-gray);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--ios-bg);
    border-radius: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--ios-purple) 0%, var(--ios-pink) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ios-gray-dark);
}

.user-balance {
    font-size: 13px;
    color: var(--ios-green);
    font-weight: 600;
}

/* ==================== Navigation ==================== */
.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ios-gray);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--ios-bg);
    color: var(--ios-gray-dark);
}

.nav-item.active {
    background: var(--ios-bg);
    color: var(--ios-blue);
    border-left-color: var(--ios-blue);
}

.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* ==================== Session Cost ==================== */
.session-cost {
    padding: 20px;
    border-top: 1px solid var(--ios-gray-light);
}

.session-cost-title {
    font-size: 13px;
    color: var(--ios-gray);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.cost-label {
    color: var(--ios-gray);
}

.cost-value {
    font-weight: 600;
    color: var(--ios-gray-dark);
}

.cost-total {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--ios-gray-light);
    font-weight: 700;
    color: var(--ios-blue);
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.content-header {
    margin-bottom: 30px;
}

.content-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--ios-gray-dark);
    margin-bottom: 8px;
}

.content-subtitle {
    font-size: 16px;
    color: var(--ios-gray);
}

/* ==================== Pages ==================== */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

/* ==================== Cards ==================== */
.card {
    background: var(--ios-card);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 4px 20px var(--ios-shadow);
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--ios-gray-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-icon {
    width: 36px;
    height: 36px;
    background: var(--ios-blue);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

/* ==================== Dashboard ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-blue-light) 100%);
    border-radius: 20px;
    padding: 25px;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.3);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

/* ==================== Studio ==================== */
.studio-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.format-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.format-btn {
    padding: 14px;
    border: 2px solid var(--ios-gray-light);
    border-radius: 12px;
    background: var(--ios-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--ios-gray-dark);
}

.format-btn:hover {
    border-color: var(--ios-blue);
}

.format-btn.active {
    background: var(--ios-blue);
    color: white;
    border-color: var(--ios-blue);
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.style-btn {
    padding: 16px;
    border: 2px solid var(--ios-gray-light);
    border-radius: 12px;
    background: var(--ios-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--ios-gray-dark);
}

.style-btn:hover {
    border-color: var(--ios-blue);
    transform: translateY(-2px);
}

.style-btn.active {
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-blue-light) 100%);
    color: white;
    border-color: var(--ios-blue);
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

/* ==================== Sliders ==================== */
.slider-container {
    margin-bottom: 20px;
}

.slider-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.slider-value-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--ios-blue);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--ios-gray-light);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ios-blue);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ios-blue);
    cursor: pointer;
    border: none;
}

/* ==================== Loading State ==================== */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    display: none;
}

.loading-state.active {
    display: block;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--ios-gray-light);
    border-top-color: var(--ios-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* ==================== Preview Area ==================== */
.preview-area {
    min-height: 400px;
    background: var(--ios-bg);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    text-align: center;
    color: var(--ios-gray);
}

.preview-placeholder-icon {
    font-size: 64px;
    margin-bottom: 15px;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 16px;
    display: none;
}

.preview-image.active {
    display: block;
}

/* ==================== Templates ==================== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.template-card {
    background: var(--ios-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--ios-shadow);
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px var(--ios-shadow-hover);
}

.template-preview {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

.template-info {
    padding: 20px;
}

.template-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--ios-gray-dark);
    margin-bottom: 8px;
}

.template-desc {
    font-size: 14px;
    color: var(--ios-gray);
    margin-bottom: 15px;
}

/* ==================== Projects ==================== */
.folders-list {
    margin-bottom: 30px;
}

.folder-item {
    background: var(--ios-bg);
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
}

.folder-item:hover {
    background: var(--ios-gray-light);
}

.folder-item.active {
    background: var(--ios-blue);
    color: white;
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.folder-icon {
    font-size: 24px;
}

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

.project-card {
    background: var(--ios-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--ios-shadow);
    transition: all 0.3s ease;
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px var(--ios-shadow-hover);
}

.project-preview {
    height: 180px;
    background: var(--ios-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.project-actions {
    padding: 15px;
    display: flex;
    gap: 10px;
}

/* ==================== Balance ==================== */
.balance-widget {
    background: linear-gradient(135deg, var(--ios-green) 0%, #2ECC71 100%);
    color: white;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.balance-amount {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
}

.balance-label {
    font-size: 14px;
    opacity: 0.9;
}

/* ==================== Alert ==================== */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease-out;
}

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

.alert-success {
    background: #E8F5E9;
    color: var(--ios-green);
    border: 2px solid var(--ios-green);
}

.alert-error {
    background: #FFEBEE;
    color: var(--ios-red);
    border: 2px solid var(--ios-red);
}

.alert-info {
    background: #E3F2FD;
    color: var(--ios-blue);
    border: 2px solid var(--ios-blue);
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--ios-card);
    border-radius: 24px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--ios-gray-dark);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ios-gray-light);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--ios-gray);
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--ios-gray);
    color: white;
}

/* ==================== Mobile Menu ==================== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--ios-blue);
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.4);
    cursor: pointer;
    z-index: 99;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 1024px) {
    .studio-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100vh;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .main-content {
        padding: 20px;
    }

    .content-title {
        font-size: 24px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .format-selector {
        grid-template-columns: 1fr;
    }

    .style-grid {
        grid-template-columns: 1fr;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .auth-card {
        padding: 30px 20px;
    }

    .auth-logo {
        width: 70px;
        height: 70px;
        font-size: 32px;
    }

    .auth-title {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .stat-value {
        font-size: 28px;
    }

    .card {
        padding: 20px;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }
}