/**
 * Home Page Styles - Google Docs-like Design
 */

:root {
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', 'Noto Sans Tamil', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ========================================
   HEADER
   ======================================== */

.home-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
}

.menu-toggle {
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: var(--bg-secondary);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    text-decoration: none;
}

.brand-logo {
    width: 40px;
    height: 40px;
}

.brand-text {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-secondary);
}

.brand-text span {
    color: var(--primary-color);
    font-weight: 600;
}

.search-bar {
    flex: 1;
    max-width: 720px;
    margin: 0 24px;
    position: relative;
}

.search-input {
    width: 100%;
    height: 48px;
    padding: 0 48px;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    font-size: 16px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: var(--text-secondary);
}

.icon-btn:hover {
    background: var(--bg-secondary);
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-primary);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

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

.sidebar-title {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-secondary);
}

.sidebar-nav {
    padding: 8px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.nav-item:hover {
    background: var(--bg-secondary);
}

.nav-item.active {
    background: #ede9fe;
    color: var(--primary-color);
}

.nav-item .icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.sidebar-footer a:hover {
    text-decoration: underline;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
    padding-top: 64px;
    min-height: 100vh;
}

/* Templates Section */
.templates-section {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    padding: 32px 0 40px;
}

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

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

.section-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.template-gallery-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.template-gallery-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.templates-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.templates-grid::-webkit-scrollbar {
    display: none;
}

.template-card {
    flex-shrink: 0;
    width: 160px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.template-preview {
    width: 160px;
    height: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    overflow: hidden;
}

.template-card:hover .template-preview {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.template-preview.blank {
    font-size: 64px;
    color: #10b981;
}

.template-preview .icon {
    font-size: 48px;
    opacity: 0.7;
}

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

.template-name {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.template-name-tamil {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Recent Documents Section */
.recent-section {
    padding: 32px 0 64px;
}

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

.recent-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.view-options {
    display: flex;
    gap: 8px;
}

.view-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.view-btn:hover,
.view-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.document-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

.document-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.document-thumbnail {
    width: 100%;
    height: 160px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 12px;
    overflow: hidden;
}

.document-thumbnail .preview-text {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
}

.document-info {
    padding: 12px 16px;
}

.document-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.document-meta .icon {
    font-size: 16px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-text {
    font-size: 14px;
    max-width: 300px;
    margin: 0 auto;
}

/* Document Menu */
.document-menu {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-primary);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.document-card:hover .document-menu {
    display: flex;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .search-bar {
        display: none;
    }

    .brand-text {
        font-size: 18px;
    }

    .template-card {
        width: 140px;
    }

    .template-preview {
        width: 140px;
        height: 176px;
    }

    .documents-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }

    .section-container {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .home-header {
        height: 56px;
    }

    .main-content {
        padding-top: 56px;
    }

    .brand-logo {
        width: 32px;
        height: 32px;
    }

    .brand-text {
        font-size: 16px;
    }

    .templates-section {
        padding: 24px 0 32px;
    }

    .template-card {
        width: 120px;
    }

    .template-preview {
        width: 120px;
        height: 150px;
    }

    .template-preview.blank {
        font-size: 48px;
    }

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