/* ============================================
   FOUNTAIN PEN COLLECTION MANAGER - STYLES
   Color Palette:
   - Primary: Deep Ink Blue (#1e3a5f)
   - Secondary: Warm Gold (#d4a574)
   - Accent: Rich Burgundy (#8b2635)
   - Neutral: Cream (#f8f6f0)
   - Text: Charcoal (#2c2c2c) & Soft Gray (#6a6a6a)
   ============================================ */

:root {
    --color-primary: #1e3a5f;
    --color-secondary: #d4a574;
    --color-accent: #8b2635;
    --color-neutral: #f8f6f0;
    --color-white: #ffffff;
    --color-text-dark: #2c2c2c;
    --color-text-gray: #6a6a6a;
    --color-border: #e0ddd7;
    --color-hover: #2e4a6f;
    --color-success: #2d7a3e;
    --color-danger: #c92a2a;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    
    --transition: all 0.3s ease;
    --border-radius: 8px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --color-primary: #5b8fce;        /* Lighter blue for better contrast */
    --color-secondary: #e8c79a;      /* Lighter gold */
    --color-accent: #d46b7a;         /* Lighter burgundy */
    --color-neutral: #1a1a1a;
    --color-white: #2d2d2d;
    --color-text-dark: #f0f0f0;      /* Brighter white text */
    --color-text-gray: #c0c0c0;      /* Lighter gray */
    --color-border: #404040;
    --color-hover: #6ba3e0;          /* Lighter hover */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-neutral);
    color: var(--color-text-dark);
    line-height: 1.6;
    transition: var(--transition);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--color-primary);
    margin-bottom: 1rem;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-hover) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-box {
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 3rem 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.pen-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--color-text-gray);
    font-size: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--color-text-dark);
    font-size: 0.9rem;
}

.form-group input {
    padding: 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--color-neutral);
    color: var(--color-text-dark);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.error-message {
    display: none;
    background: #fee;
    color: var(--color-danger);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
    background: var(--color-white);
    border-bottom: 2px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.3rem;
}

.nav-brand .pen-icon {
    font-size: 1.8rem;
}

.brand-text {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    color: var(--color-primary);
}

.nav-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-link {
    background: none;
    border: none;
    color: var(--color-text-gray);
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: var(--color-neutral);
    color: var(--color-primary);
}

.theme-toggle {
    background: var(--color-neutral);
    border: 2px solid var(--color-border);
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: scale(1.1);
}

.btn-logout {
    background: var(--color-accent);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-logout:hover {
    background: #6d1e28;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-white);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
    background: var(--color-primary);
    color: white;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: #a82222;
}

/* ============================================
   VIEWS
   ============================================ */

.view {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--color-border);
}

.view-header h1 {
    font-size: 2.5rem;
    margin: 0;
}

.view-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    min-width: 300px;
    background: var(--color-white);
    color: var(--color-text-dark);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.sort-select, .filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 1rem;
    min-width: 180px;
    background: var(--color-white);
    color: var(--color-text-dark);
    transition: var(--transition);
    cursor: pointer;
}

.sort-select:focus, .filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.sort-select:hover, .filter-select:hover {
    border-color: var(--color-primary);
}

.filter-select {
    min-width: 150px;
}

/* ============================================
   HOME / LANDING VIEW
   ============================================ */

.hero-section {
    text-align: center;
    padding: 3rem 0 2rem;
}

.hero-title {
    font-size: 3rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--color-text-gray);
}

.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin: 3rem 0;
}

.landing-card {
    background: var(--color-white);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
}

.landing-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-secondary);
}

.landing-card-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.landing-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.landing-card p {
    color: var(--color-text-gray);
    margin-bottom: 1rem;
}

.landing-card-count {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-secondary);
    font-family: 'Playfair Display', serif;
}

.quick-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* ============================================
   ITEMS GRID
   ============================================ */

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.item-card {
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
    border: 2px solid transparent;
}

.item-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-secondary);
}

.item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--color-neutral) 0%, var(--color-border) 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-gray);
    font-size: 3rem;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-content {
    padding: 1.5rem;
}

.item-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--color-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.4;
    max-height: 3.2em; /* Show up to ~2 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.item-brand {
    color: var(--color-text-gray);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.item-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.item-detail {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.item-detail-label {
    font-weight: 600;
    color: var(--color-text-gray);
}

.item-detail-value {
    color: var(--color-text-dark);
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    flex: 1;
}

/* ============================================
   LIST VIEW (for Maintenance Log)
   ============================================ */

.list-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.list-item {
    background: var(--color-white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-secondary);
}

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.list-item-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
}

.list-item-date {
    color: var(--color-text-gray);
    font-size: 0.9rem;
}

.list-item-body {
    color: var(--color-text-dark);
    line-height: 1.6;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--color-white);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--color-border);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--color-text-gray);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--color-danger);
}

.modal-body {
    padding: 2rem;
}

#itemForm {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ============================================
   GALLERY MODAL
   ============================================ */

.gallery-modal {
    max-width: 90%;
    max-height: 90vh;
}

.gallery-content {
    padding: 2rem;
    text-align: center;
}

.gallery-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    cursor: zoom-in;
}

.gallery-info {
    margin-top: 1.5rem;
    text-align: left;
}

.gallery-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--color-border);
}

.gallery-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.gallery-btn:hover {
    background: var(--color-hover);
    transform: translateY(-2px);
}

.gallery-counter {
    font-weight: 600;
    color: var(--color-primary);
    min-width: 80px;
    text-align: center;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    border: 4px solid var(--color-neutral);
    border-top: 4px solid var(--color-secondary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

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

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .landing-grid {
        grid-template-columns: 1fr;
    }
    
    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .view-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
        min-width: auto;
    }
    
    .hero-title {
        font-size: 2rem;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-success {
    background: var(--color-success);
    color: white;
}

.badge-warning {
    background: var(--color-secondary);
    color: var(--color-text-dark);
}

.badge-info {
    background: var(--color-primary);
    color: white;
}

/* ========================================
   GALLERY NAVIGATION ARROWS - ADD TO styles.css
   ======================================== */

/* Gallery image container */
.gallery-image-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: visible;
}

.gallery-image-container img {
    display: block;
    max-width: 100%;
    height: auto;
    transition: transform 0.3s ease;
}

/* Zoomed state - image expands to 150% */
.gallery-image-container img.zoomed {
    transform: scale(1.5);
    cursor: zoom-out !important;
    z-index: 100;
    position: relative;
}

/* Navigation arrows - positioned on image edges */
.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* Left arrow positioning */
.gallery-arrow-left {
    left: 15px;
}

/* Right arrow positioning */
.gallery-arrow-right {
    right: 15px;
}

/* Arrow hover effects */
.gallery-arrow:hover {
    background: rgba(0, 0, 0, 0.75);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Arrow active state */
.gallery-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

/* Arrow SVG styling */
.gallery-arrow svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Image counter overlay - positioned at top center */
.gallery-counter-overlay {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .gallery-arrow {
        width: 40px;
        height: 40px;
    }
    
    .gallery-arrow-left {
        left: 10px;
    }
    
    .gallery-arrow-right {
        right: 10px;
    }
    
    .gallery-arrow svg {
        width: 30px;
        height: 30px;
    }
    
    .gallery-counter-overlay {
        font-size: 0.8rem;
        padding: 6px 12px;
        top: 10px;
    }
}

/* Hide arrows on very small screens to avoid blocking image */
@media (max-width: 480px) {
    .gallery-arrow {
        width: 35px;
        height: 35px;
        opacity: 0.8;
    }
    
    .gallery-arrow svg {
        width: 25px;
        height: 25px;
    }
}

/* Keyboard navigation hint (optional) */
.gallery-image-container:focus-within .gallery-arrow {
    opacity: 1;
}

/* Smooth fade-in for arrows */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.gallery-arrow {
    animation: fadeIn 0.3s ease-in;
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

[data-theme="dark"] .gallery-arrow {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

[data-theme="dark"] .gallery-arrow:hover {
    background: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .gallery-counter-overlay {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ========================================
   LIGHT MODE ADJUSTMENTS
   ======================================== */

[data-theme="light"] .gallery-arrow {
    background: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .gallery-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .gallery-counter-overlay {
    background: rgba(0, 0, 0, 0.75);
}