/* Ainet Tagging ODP Mobile */

.app-logo {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

.login-logo,
.app-logo.login-logo {
    width: min(240px, 78%);
    height: auto;
    max-height: 72px;
    border-radius: 0;
    box-shadow: none;
    object-fit: contain;
}

:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --dark: #134e4a;
    --light: #f0fdfa;
    --border: #ccfbf1;
    --bottom-nav-h: 64px;
    --header-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0fdfa;
    color: #134e4a;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

#loginScreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.login-card h1 {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 4px;
    color: var(--dark);
    line-height: 1.3;
}

.login-card .subtitle {
    text-align: center;
    color: #6c757d;
    font-size: .85rem;
    margin-bottom: 24px;
}

.login-card .form-group { margin-bottom: 16px; }

.login-card label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #495057;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15,118,110,.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s, transform .1s;
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: #0f766e; }
.btn-sm { padding: 6px 10px; font-size: .78rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    border-color: rgba(255,255,255,.3);
    color: #fff;
}

#appShell {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    height: var(--header-h);
    background: linear-gradient(135deg, #0f766e, #115e59);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header .user-name {
    font-size: .75rem;
    opacity: .85;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.app-content:has(#tabMap.active) { padding: 0; }

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(15,118,110,.08);
}

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

.stat-card .label {
    font-size: .68rem;
    color: #6c757d;
    margin-top: 2px;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .9rem;
    margin-bottom: 12px;
    background: #fff;
}

.filter-bar {
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(15,118,110,.08);
}

.filter-bar .filter-row { display: flex; gap: 8px; }

.filter-bar select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .85rem;
    min-width: 0;
}

.item-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(15,118,110,.08);
    border-left: 4px solid var(--primary);
}

.item-card.draft { border-left-color: #9ca3af; }
.item-card.tagged { border-left-color: var(--info); }
.item-card.active { border-left-color: var(--success); }
.item-card.maintenance { border-left-color: var(--warning); }
.item-card.inactive { border-left-color: var(--danger); }

.item-card .card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.item-card .card-title {
    font-weight: 700;
    font-size: .92rem;
    line-height: 1.3;
}

.item-card .card-code {
    font-size: .78rem;
    color: #6c757d;
    font-family: ui-monospace, monospace;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-primary { background: #ccfbf1; color: #115e59; }
.badge-secondary { background: #e5e7eb; color: #374151; }

.occ-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    margin: 8px 0;
}

.occ-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #14b8a6, #0f766e);
}

.item-card .card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: .4;
    display: block;
}

.hint-box {
    background: #ccfbf1;
    color: #115e59;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: .82rem;
    margin-bottom: 12px;
    line-height: 1.45;
}

.fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(22,163,74,.4);
    cursor: pointer;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(15,118,110,.08);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: #6c757d;
    font-size: .65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
}

.nav-tab i { font-size: 1.1rem; }
.nav-tab.active { color: var(--primary); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s, visibility .25s;
}

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

.modal-sheet {
    background: #fff;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .3s ease;
}

.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-sheet-tall { max-height: 92vh; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.modal-header h3 { font-size: 1rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #6c757d;
    cursor: pointer;
}

.modal-body { padding: 16px 20px 24px; }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #495057;
}
.form-group .required { color: var(--danger); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 0 20px 20px;
}
.modal-footer .btn { flex: 1; }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.7);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.port-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 12px 0 16px;
}

.port-cell {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    min-height: 78px;
    cursor: pointer;
}

.port-cell.empty { background: #f8fafc; }
.port-cell.occupied { background: #dcfce7; border-color: #86efac; }
.port-cell.damaged { background: #fee2e2; border-color: #fca5a5; }
.port-cell.reserved { background: #fef3c7; border-color: #fcd34d; }

.port-num {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    color: #6c757d;
}

.port-name {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    margin-top: 4px;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
}

.detail-hero {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(15,118,110,.08);
}

.detail-hero h2 {
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.detail-meta {
    font-size: .8rem;
    color: #6c757d;
    line-height: 1.5;
}

.photo-preview {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 10px;
    margin-top: 10px;
}

#tabMap { position: relative; }

.odp-map {
    height: calc(100vh - var(--header-h) - var(--bottom-nav-h) - var(--safe-bottom));
    width: 100%;
}

.map-legend {
    position: absolute;
    left: 12px;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
    z-index: 500;
    background: rgba(255,255,255,.95);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    gap: 10px;
    font-size: .72rem;
    font-weight: 600;
    color: #134e4a;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

.map-legend span { display: inline-flex; align-items: center; gap: 4px; }

.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 10px 12px; font-size: .85rem; line-height: 1.45; }

@media (min-width: 720px) {
    .bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
    .fab { right: calc(50% - 280px); }
}
