@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --panel-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --font-sans: 'Outfit', sans-serif;
    --shadow-premium: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

.container {
    width: 95%;
    max-width: 1750px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header styling */
header {
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInDown 0.6s ease;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #a5b4fc, #6366f1, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Glassmorphism Panels */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-premium);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    box-shadow: 0 25px 30px -5px rgb(0 0 0 / 0.6), 0 12px 15px -6px rgb(0 0 0 / 0.6);
}

/* Upload Area */
.upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px dashed rgba(99, 102, 241, 0.4);
    border-radius: 12px;
    padding: 3rem 2rem;
    cursor: pointer;
    background: rgba(99, 102, 241, 0.02);
    transition: all 0.3s ease;
    text-align: center;
}

.upload-container:hover, .upload-container.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
    transform: scale(1.01);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent);
    animation: bounce 2s infinite;
}

.upload-text h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.upload-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#file-input {
    display: none;
}

.upload-container.native-file-input-mode #file-input {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Client Details Card */
.client-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-size: 1.05rem;
    color: var(--text-primary);
    font-weight: 600;
}

.detail-value.highlight {
    color: #a5b4fc;
}

/* Search bar styling */
.search-container {
    margin-bottom: 1.5rem;
    position: relative;
}

.search-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    padding-left: 2.5rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Table styling */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
    max-height: 550px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(30, 41, 59, 0.9);
    padding: 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 1rem;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Highlight row being edited */
tr.product-row:focus-within td {
    background: rgba(11, 185, 128, 0.08) !important;
    border-bottom: 1px solid rgba(11, 185, 128, 0.25) !important;
}

tr.product-row:focus-within td:first-child {
    box-shadow: inset 4px 0 0 0 #0bb980;
}

/* Reference and Serial columns */
.ref-badge {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: monospace;
    font-weight: 600;
    font-size: 0.85rem;
}

.serial-text {
    font-family: monospace;
    color: var(--text-secondary);
}

/* Stock Input styling */
.stock-cell {
    position: relative;
    width: 120px;
}

.stock-input {
    width: 90px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    padding: 0.5rem;
    color: var(--danger);
    font-weight: 700;
    font-family: var(--font-sans);
    text-align: center;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.stock-input:focus {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.stock-input.filled {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.stock-input.filled:focus {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Remove spin buttons from number input */
.stock-input::-webkit-outer-spin-button,
.stock-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.stock-input {
    -moz-appearance: textfield;
}

/* Saving indicator states */
.save-status {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.save-status.saving {
    opacity: 1;
    color: var(--accent);
}

.save-status.success {
    opacity: 1;
    color: var(--success);
    animation: fadeOutShort 1.5s forwards;
}

/* Footer summary & actions */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1.5rem;
}

.summary-stats {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.8rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    font-family: var(--font-sans);
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes fadeOutShort {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }
    .panel {
        padding: 1.5rem;
    }
    .table-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .summary-stats {
        justify-content: space-between;
    }
    .btn {
        width: 100%;
    }
}

/* Logo Styling */
.logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}
.logo-img {
    height: 88px;
    width: auto;
    filter: drop-shadow(0 2px 10px rgba(59, 130, 246, 0.25));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.logo-img:hover {
    transform: scale(1.04);
}

/* Observations Column & Button */
.obs-cell {
    width: 60px;
}
.obs-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    outline: none;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.obs-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}
.obs-btn.has-obs {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #f59e0b;
    animation: pulseOrange 2s infinite;
}
.obs-btn.has-obs:hover {
    background: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

@keyframes pulseOrange {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}
.modal.show {
    display: flex;
}
.modal-content {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}
.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}
.close-modal {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
}
.close-modal:hover {
    color: var(--text-primary);
}
.modal-body textarea {
    width: 100%;
    height: 120px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    resize: none;
    transition: border-color 0.2s ease;
}
.modal-body textarea:focus {
    border-color: var(--accent);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes pulseGreen {
    0% {
        transform: scale(1);
        text-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        transform: scale(1.05);
        text-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(1);
        text-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Orientation warning overlay */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    #portrait-overlay {
        display: flex !important;
    }
}

@keyframes rotateDevice {
    0% { transform: rotate(0deg); }
    50% { transform: scale(1.05) rotate(-90deg); }
    100% { transform: rotate(0deg); }
}
