/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    --primary: #6c5ce7;
    --primary-dark: #5a4bd1;
    --secondary: #00b894;
    --accent: #fd79a8;
    --dark: #2d3436;
    --gray: #636e72;
    --light-gray: #dfe6e9;
    --bg: #f8f9fa;
    --white: #ffffff;
    --danger: #d63031;
    --warning: #fdcb6e;
    --success: #00b894;
    --info: #74b9ff;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 5px 25px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* ============================================
   Navbar
   ============================================ */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 0;
}

.navbar .container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}
.navbar-brand:hover { color: var(--primary-dark); }
.navbar-brand i { margin-right: 0.3rem; }

.navbar-search {
    flex: 1;
    max-width: 400px;
}
.navbar-search form {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--light-gray);
}
.navbar-search input {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    outline: none;
}
.navbar-search button {
    padding: 0.5rem 1rem;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}
.navbar-search button:hover { background: var(--primary-dark); }

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--dark);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.navbar-menu a { color: var(--gray); font-weight: 500; font-size: 0.9rem; }
.navbar-menu a:hover { color: var(--primary); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.nav-user span { color: var(--dark); font-weight: 500; font-size: 0.9rem; }

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    justify-content: center;
}
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #00a884; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; color: white; }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-outline {
    background: none;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #ffeaea; color: var(--danger); border: 1px solid #ffcccc; }
.alert-success { background: #e6fff7; color: #00856a; border: 1px solid #b3ffe0; }
.alert-info { background: #e8f4fd; color: #2980b9; border: 1px solid #b8dff5; }
.alert-warning { background: #fff8e1; color: #856404; border: 1px solid #ffeeba; }

/* ============================================
   Auth Pages
   ============================================ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem 0;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}

.auth-card h1 {
    font-size: 1.6rem;
    margin-bottom: 0.3rem;
    color: var(--dark);
}

.auth-subtitle {
    color: var(--gray);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--dark);
}

.auth-form input, .form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--white);
}

.auth-form input:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
}

.otp-input {
    text-align: center;
    font-size: 1.5rem !important;
    letter-spacing: 0.5rem;
    font-weight: 700;
}

.auth-links {
    margin-top: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.auth-links a { font-size: 0.85rem; }

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #a29bfe 100%);
    color: white;
    padding: 3rem 2rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    text-align: center;
}
.hero h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.hero p { font-size: 1.1rem; opacity: 0.9; max-width: 600px; margin: 0 auto; }

/* ============================================
   Project Grid
   ============================================ */
.section-title {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.project-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}
.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.project-card-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--light-gray);
}

.project-card-body {
    padding: 1.2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.project-card-category {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.project-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--dark);
}
.project-card-title a { color: inherit; }
.project-card-title a:hover { color: var(--primary); }

.project-card-desc {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 1rem;
    flex: 1;
}

.project-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.8rem;
    border-top: 1px solid var(--light-gray);
}

.project-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--secondary);
}
.project-price .original-price {
    font-size: 0.85rem;
    color: var(--gray);
    text-decoration: line-through;
    margin-left: 0.3rem;
    font-weight: 400;
}

.project-card-meta {
    display: flex;
    gap: 0.8rem;
    font-size: 0.8rem;
    color: var(--gray);
}

/* ============================================
   Project Detail Page
   ============================================ */
.project-detail {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    align-items: start;
}

.project-main { }

.project-main h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.project-meta {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--gray);
    flex-wrap: wrap;
}
.project-meta span i { margin-right: 0.3rem; }

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tech-badge {
    padding: 0.25rem 0.6rem;
    background: #eef0ff;
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.project-description {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}
.project-description h2, .project-description h3 { margin: 1.5rem 0 0.8rem; }
.project-description p { margin-bottom: 1rem; }
.project-description pre {
    background: var(--dark);
    color: #dfe6e9;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 1rem;
}
.project-description code { font-family: 'Fira Code', monospace; font-size: 0.9rem; }
.project-description ul, .project-description ol { padding-left: 1.5rem; margin-bottom: 1rem; }

/* Screenshots Gallery */
.screenshots-section {
    margin-bottom: 1.5rem;
}
.screenshots-section h2 { margin-bottom: 1rem; }
.screenshots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.screenshot-thumb {
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    height: 150px;
    object-fit: cover;
    width: 100%;
    border: 1px solid var(--light-gray);
}
.screenshot-thumb:hover { transform: scale(1.03); box-shadow: var(--shadow); }

/* Sidebar purchase card */
.project-sidebar {
    position: sticky;
    top: 80px;
}

.purchase-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}

.purchase-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}
.purchase-price .original {
    font-size: 1.1rem;
    color: var(--gray);
    text-decoration: line-through;
    font-weight: 400;
}

.purchase-info {
    margin-bottom: 1.5rem;
}
.purchase-info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.85rem;
}
.purchase-info-item:last-child { border-bottom: none; }
.purchase-info-label { color: var(--gray); }
.purchase-info-value { font-weight: 600; }

.btn-buy {
    width: 100%;
    padding: 0.8rem;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.already-purchased {
    text-align: center;
    padding: 1rem;
    background: #e6fff7;
    border-radius: var(--radius-sm);
    color: #00856a;
    font-weight: 600;
}

/* Version history */
.version-list {
    margin-top: 1.5rem;
}
.version-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.85rem;
}
.version-item:last-child { border-bottom: none; }
.version-number { font-weight: 700; color: var(--primary); }

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    margin: 2rem 0;
}
.page-btn {
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--light-gray);
    color: var(--dark);
    font-weight: 500;
    transition: var(--transition);
}
.page-btn:hover, .page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.page-dots { padding: 0.5rem; color: var(--gray); }

/* ============================================
   Admin Layout
   ============================================ */
.admin-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    min-height: calc(100vh - 200px);
}

.admin-sidebar {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 80px;
}

.admin-sidebar h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 1px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--light-gray);
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    color: var(--dark);
    border-radius: var(--radius-sm);
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
    transition: var(--transition);
}
.admin-nav a:hover, .admin-nav a.active {
    background: #eef0ff;
    color: var(--primary);
}
.admin-nav a i { width: 20px; text-align: center; }

.admin-content { }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
}
.stat-icon.purple { background: var(--primary); }
.stat-icon.green { background: var(--secondary); }
.stat-icon.pink { background: var(--accent); }
.stat-icon.blue { background: var(--info); }

.stat-info h3 { font-size: 1.5rem; line-height: 1; }
.stat-info p { font-size: 0.8rem; color: var(--gray); }

/* Tables */
.table-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table-card-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--light-gray);
}
.table-card-header h2 { font-size: 1.1rem; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--light-gray);
}
.data-table th {
    font-weight: 600;
    color: var(--gray);
    background: var(--bg);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}
.data-table tr:hover { background: #fafbfc; }

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #e6fff7; color: #00856a; }
.badge-danger { background: #ffeaea; color: var(--danger); }
.badge-warning { background: #fff8e1; color: #856404; }
.badge-info { background: #e8f4fd; color: #2980b9; }
.badge-secondary { background: #f0f0f0; color: var(--gray); }

/* Forms in Admin */
.form-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.form-card h2 {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--light-gray);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.85rem;
}

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

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--light-gray);
}

/* Settings form */
.settings-section {
    margin-bottom: 2rem;
}
.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

/* ============================================
   Lightbox
   ============================================ */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 90%; max-height: 90vh; border-radius: var(--radius); }
.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    background: none;
    border: none;
}

/* ============================================
   Search Results
   ============================================ */
.search-header {
    margin-bottom: 1.5rem;
}
.search-header h1 { font-size: 1.4rem; }
.search-header p { color: var(--gray); }

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; opacity: 0.4; }
.empty-state h3 { margin-bottom: 0.5rem; color: var(--dark); }

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--dark);
    color: #b2bec3;
    padding: 2.5rem 0 1rem;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.footer-col h3 { color: white; margin-bottom: 0.75rem; }
.footer-col h4 { color: white; margin-bottom: 0.75rem; font-size: 0.95rem; }
.footer-col p { font-size: 0.85rem; }
.footer-col a { display: block; color: #b2bec3; font-size: 0.85rem; margin-bottom: 0.3rem; }
.footer-col a:hover { color: white; }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .navbar .container { flex-wrap: wrap; }
    .navbar-search { order: 3; flex: 0 0 100%; max-width: 100%; }
    .navbar-toggle { display: block; margin-left: auto; }
    .navbar-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 4;
        padding-top: 0.5rem;
    }
    .navbar-menu.open { display: flex; }
    .nav-user { flex-direction: column; align-items: flex-start; }

    .project-detail { grid-template-columns: 1fr; }
    .project-sidebar { position: static; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; }
    .footer-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .project-grid { grid-template-columns: 1fr; }
}
