:root {
    --bg:#f7f7f9;
    --card:#ffffff;
    --accent:#6b2d2d;
    --muted:#666;
}
* {
    box-sizing:border-box
}
body {
    font-family:system-ui,Segoe UI,Roboto,Arial;
    background:var(--bg);
    color:#222;
    margin:0;
    padding:0;
    padding-top:env(safe-area-inset-top);
    padding-bottom:env(safe-area-inset-bottom);
}
header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:0.75rem 1.25rem;
    padding-left:max(1.25rem, env(safe-area-inset-left));
    padding-right:max(1.25rem, env(safe-area-inset-right));
    background:var(--card);
    box-shadow:0 1px 2px rgba(0,0,0,.05);
    position: sticky;
    top: 0;
    z-index: 9999;
}
header h1 {
    margin:0;
    font-size:1.1rem;
    color:var(--accent);
}
#auth-area {
    display:flex;
    gap:.5rem;
    align-items:center;
}
main {
    padding:1rem;
    max-width:980px;
    margin:1rem auto;
    padding-top: 0;
}
section {
    background:var(--card);
    padding:1rem;
    margin-bottom:1rem;
    border-radius:6px;
    box-shadow:0 1px 2px rgba(0,0,0,.04);
}
.hidden {
    display:none !important;
}
#list table {
    width:100%;
    border-collapse:collapse;
}
#list th,#list td {
    padding:.5rem;
    border-bottom:1px solid #eee;
    text-align:left;
}
button {
    background:var(--accent);
    color:#fff;
    border:0;
    padding:.45rem .6rem;
    border-radius:4px;
    cursor:pointer;
}
button:disabled {
    opacity:.5;
    cursor:not-allowed;
}
input,select {
    padding:.4rem;
    border:1px solid #ddd;
    border-radius:4px;
}
.form-row {
    display:flex;
    gap:.5rem;
    align-items:center;
    margin-top:.5rem;
}
label {
    display:block;
    margin-top:.5rem;
}
footer {
    padding:1rem;
    text-align:center;
    color:var(--muted);
}

/* Estilos de Modales */
.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}
.modal.hidden {
    display: none;
}
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}
.modal-content {
    position: relative;
    z-index: 2;
    background: var(--card);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    margin: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}
.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--accent);
}
.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.modal-close:hover {
    color: var(--accent);
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    padding-top: 0;
}
.modal-body label {
    margin-top: 1rem;
    font-weight: 500;
    color: #333;
}
.modal-body input {
    width: 100%;
    padding: 0.6rem;
    margin-top: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}
.modal-body input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(107, 45, 45, 0.1);
}
.modal-body .form-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}
.modal-body .form-row button {
    padding: 0.45rem 1rem;
    flex: 0 1 auto;
    min-width: 100px;
}
.modal-body .form-row button:first-child {
    background: var(--accent);
}
.modal-body .form-row button:last-child {
    background: #999;
}
.modal-body .form-row button:hover {
    opacity: 0.9;
}
.form-row-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}
.form-row-inline label {
    margin-top: 0;
}
textarea#edit-comentarios {
    height: 75px;
}
textarea#edit-notasconsumo {
    height: 75px;
}

/* Modal pequeño */
.modal-small {
    max-width: 350px;
}

/* Modal de notificación */
.modal-notification {
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}
.modal-notification #notification-content {
    padding: 2rem;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.modal-notification h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    color: var(--accent);
}
.modal-notification p {
    margin: 0.5rem 0;
    color: #555;
}
.modal-notification .notification-success {
    color: #27ae60;
}
.modal-notification .notification-error {
    color: #e74c3c;
}
.modal-notification .notification-info {
    color: var(--accent);
}

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#list {
    display: block;
    width: 100%;
}

/* Estilos para las Cards y Grupos */
#list-section {
    background: transparent;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}
#list-controls {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Sección de no autenticado */
#not-logged-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}
.not-logged-message {
    text-align: center;
    background: var(--card);
    padding: 2rem;
    border-radius: 8px;
    max-width: 400px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.not-logged-message h2 {
    color: var(--accent);
    margin-top: 0;
}
.not-logged-message p {
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
}
.not-logged-message button {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
}
.shelf-group {
    margin-bottom: 2.5rem;
    background: var(--card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.shelf-header {
    background: linear-gradient(135deg, var(--accent) 0%, #5a2323 100%);
    color: white;
    padding: 1rem 1.25rem;
    margin: 0;
    font-size: 1.15rem;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    background: #ffffff;
    padding: 1.5rem;
    min-height: 100px;
}
.bottle-card {
    background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
    border: 2px solid #f0e6e6;
    border-radius: 10px;
    padding: 1.25rem;
    position: relative;
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}
.bottle-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(107, 45, 45, 0.15);
    border-color: var(--accent);
}
.bottle-pos {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--accent);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(107, 45, 45, 0.2);
}
.bottle-title {
    font-weight: bold;
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
    margin-top: 0;
    color: var(--accent);
    padding-right: 3.5rem;
    word-wrap: break-word;
}
.bottle-info {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.6rem;
    line-height: 1.5;
}
.bottle-info b {
    color: var(--accent);
    font-weight: 600;
}
.bottle-actions {
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
}
.bottle-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* User Menu */
.user-profile {
    position: relative;
}
.user-profile.hidden {
    display: none;
}
.user-menu-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}
.user-menu-header:hover {
    background: rgba(107, 45, 45, 0.1);
}
.user-menu-header svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
    flex-shrink: 0;
}
.user-menu-header span {
    font-weight: 600;
    color: #222;
    flex: 1;
    word-break: break-word;
    max-width: 150px;
}
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 125px;
    z-index: 999;
}
.user-dropdown.hidden {
    display: none;
}
.logout-btn {
    width: 100%;
    background: transparent;
    color: var(--accent);
    border: none;
    padding: 0.75rem 1rem;
    text-align: left;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.9rem;
}
.logout-btn:hover {
    background: #f5f5f5;
}

/* Posicionar auth-area como relative para el dropdown */
#auth-area {
    position: relative;
}

/* Pestañas */
.tabs-container {
    margin-top: 1rem;
}

.tabs-header {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #ddd;
    margin-bottom: 0;
    position: sticky;
    top: calc(1.5rem + 60px);
    z-index: 2;
    background: var(--bg);
    align-items: center;
    justify-content: space-between;
}

.tabs-buttons {
    display: flex;
    gap: 0;
}

#btn-refresh {
    flex-shrink: 0;
    margin-left: auto;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.tab-button {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.tab-button:hover {
    background: #f5f5f5;
    color: #222;
}

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

.tab-content {
    display: none;
    padding: 1rem 0;
}

.tab-content.active {
    display: block;
}

/* Responsive: en móvil, ocultar el user-status text */
@media (max-width: 600px) {
    #user-status {
        display: none;
    }
    #auth-area {
        gap: 0.5rem;
    }
    .user-menu-header span {
        max-width: 100px;
    }
    
    .tab-button {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
}

