* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background-image: url('Assets/BACK.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: white;
    padding: 40px;
    text-align: center;
}

.header-logo {
    width: 150px;
    height: 150px;
    max-width: 150px;
    max-height: 150px;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    /* filter: brightness(0) invert(1); */ /* Temporarily disabled for testing */
    object-fit: contain;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
    background: #ffc107;
    color: #333;
    padding: 15px 30px;
    border-radius: 10px;
    display: inline-block;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.total-price {
    margin-top: 20px;
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: inline-block;
    font-size: 1.3em;
    font-weight: 600;
}

.total-label {
    margin-right: 10px;
    opacity: 0.9;
}

.total-value {
    font-size: 1.4em;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Database Actions */
.database-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.database-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
}

.btn-save {
    background: #28a745;
    color: white;
}

.btn-save:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn-load {
    background: #007bff;
    color: white;
}

.btn-load:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
}

.database-actions .btn svg {
    width: 18px;
    height: 18px;
}

/* Search Bar */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 30px auto;
    padding: 0 20px;
}

.search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.search-icon {
    position: absolute;
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #999;
    pointer-events: none;
}

/* Date Range Filter */
.date-filter-container {
    max-width: 800px;
    margin: 20px auto 30px;
    padding: 0 20px;
}

.date-filter-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 3px solid #ffc107;
    flex-wrap: wrap;
    justify-content: center;
}

.date-filter-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 180px;
}

.date-filter-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-input {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.date-input:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.date-filter-separator {
    font-size: 24px;
    color: #22c55e;
    font-weight: bold;
    padding-bottom: 8px;
    align-self: flex-end;
}

.btn-clear {
    background: #6c757d;
    color: white;
    padding: 12px 25px;
    font-size: 14px;
    white-space: nowrap;
}

.btn-clear:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Form Section */
.form-section {
    padding: 30px 40px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.form-section h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 1.8em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group-full textarea {
    min-height: 100px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    background: white;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Match textarea height to input when side by side */
.side-by-side-fields .form-group textarea {
    min-height: auto;
    height: 48px; /* Match input height: padding (12px*2) + line-height */
    resize: none;
    overflow-y: auto;
}

/* Ensure all fields in side-by-side layout have same height */
.side-by-side-fields .form-group input,
.side-by-side-fields .form-group textarea {
    height: 48px;
    box-sizing: border-box;
}

/* Copy button styling */
.copy-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.3s ease;
    z-index: 10;
}

.copy-btn:hover {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.copy-btn svg {
    width: 18px;
    height: 18px;
}

/* Paste button styling */
.paste-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.3s ease;
    z-index: 10;
}

.paste-btn:hover {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.paste-btn svg {
    width: 18px;
    height: 18px;
}

/* KEY D'ACTIVATION field styling - wider and monospace */
#keyActivation {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 0.5px;
    width: 100%;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    max-width: 400px;
    margin: 0 auto;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4);
}

.btn-large {
    padding: 18px 50px;
    font-size: 18px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-edit {
    background: #28a745;
    color: white;
    padding: 8px 15px;
    font-size: 14px;
    margin-right: 5px;
}

.btn-edit:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 8px 15px;
    font-size: 14px;
}

.btn-delete:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Icon Buttons */
.action-buttons-container {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px !important;
    background: #f8f9fa;
    border-radius: 8px;
    min-width: 60px;
    width: auto !important;
}

.action-buttons-container > * {
    display: block !important;
    width: 36px !important;
    flex-shrink: 0 !important;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease;
    width: 36px !important;
    height: 36px !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-edit-icon {
    color: #28a745;
}

.btn-edit-icon:hover {
    background: rgba(40, 167, 69, 0.1);
    transform: translateY(-2px);
}

.btn-cancel-edit {
    color: #6c757d;
}

.btn-cancel-edit:hover {
    background: rgba(108, 117, 125, 0.1);
    transform: translateY(-2px);
}

.btn-print {
    color: #007bff;
}

.btn-print:hover {
    background: rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

.btn-whatsapp-table {
    color: #25D366 !important;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 36px !important;
    height: 36px !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    padding: 8px !important;
    border-radius: 6px !important;
    align-items: center !important;
    justify-content: center !important;
}

.btn-whatsapp-table:hover {
    background: rgba(37, 211, 102, 0.1) !important;
    transform: translateY(-2px);
}

.btn-whatsapp-table svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.btn-delete-icon {
    color: #dc3545;
}

.btn-delete-icon:hover {
    background: rgba(220, 53, 69, 0.1);
    transform: translateY(-2px);
}

/* Table Section */
.table-section {
    padding: 30px 40px;
}

.table-section h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 1.8em;
}

.table-container {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 1200px;
}

thead {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

thead th {
    padding: 18px 15px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
    min-height: 50px;
}

/* Hidden columns - shown only when editing */
.hidden-column {
    display: none !important;
}

/* Filterable headers */
.filterable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.3s ease;
}

.filterable-header:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.filter-icon {
    margin-left: 8px;
    font-size: 1em;
    opacity: 1;
    transition: all 0.3s ease;
    display: inline-block;
    vertical-align: middle;
}

.filterable-header:hover .filter-icon {
    opacity: 1;
    transform: scale(1.15);
}

/* Column filter popup */
.column-filter-popup {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.column-filter-popup label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.column-filter-popup label:hover {
    background-color: #f8f9fa;
}

.column-filter-popup input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr.expired-row {
    background-color: #ffe6e6 !important;
    border-left: 4px solid #dc3545;
}

tbody tr.expired-row:hover {
    background-color: #ffcccc !important;
}

tbody tr.expired-row td {
    color: #dc3545;
    font-weight: 500;
}

tbody td {
    padding: 15px;
    font-size: 14px;
    color: #555;
}

tbody td:last-child {
    white-space: normal;
}

/* Force vertical layout for action buttons - VERY SPECIFIC SELECTORS */
table tbody tr td:last-child .action-buttons-container,
tbody td:last-child .action-buttons-container,
td:last-child .action-buttons-container,
.action-buttons-container {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 10px !important;
    background: #f8f9fa !important;
    border-radius: 8px !important;
    min-width: 60px !important;
    width: auto !important;
    max-width: 80px !important;
}

table tbody tr td:last-child .action-buttons-container > *,
tbody td:last-child .action-buttons-container > *,
td:last-child .action-buttons-container > *,
.action-buttons-container > * {
    display: block !important;
    width: 36px !important;
    flex-shrink: 0 !important;
    float: none !important;
    clear: both !important;
}

table tbody tr td:last-child .btn-icon,
tbody td:last-child .btn-icon,
td:last-child .btn-icon,
.action-buttons-container .btn-icon {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    margin: 0 auto !important;
    float: none !important;
    clear: both !important;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    font-size: 1.2em;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .database-actions {
        flex-direction: column;
        padding: 15px;
    }

    .database-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group-full {
        grid-column: 1;
    }

    .form-section,
    .table-section {
        padding: 20px;
    }

    .table-container {
        overflow-x: scroll;
    }

    .date-filter-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .date-filter-separator {
        align-self: center;
        padding: 10px 0;
        transform: rotate(90deg);
    }

    .date-filter-group {
        min-width: 100%;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

tbody tr {
    animation: fadeIn 0.3s ease;
}

/* Popup Styles */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.popup-overlay.active {
    display: flex;
}

.popup-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.popup-content h3 {
    margin-bottom: 25px;
    color: #333;
    font-size: 1.8em;
    text-align: center;
}

.popup-form-group {
    margin-bottom: 25px;
}

/* API Key Popup Styles */
.api-key-popup {
    max-width: 600px !important;
}

.api-key-popup #apiKeyDisplay {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    word-break: break-all;
}

.api-key-popup #copyApiKeyBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.api-key-popup #copyApiKeyBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4);
}

.api-key-popup #copyApiKeyBtn svg {
    width: 18px;
    height: 18px;
}

/* WhatsApp Button Styles */
.btn-whatsapp {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.btn-whatsapp:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.4);
    background: linear-gradient(135deg, #128C7E 0%, #25D366 100%);
}

.btn-whatsapp svg {
    width: 18px;
    height: 18px;
}

.popup-form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #555;
    font-size: 1em;
}

.popup-select {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.popup-select:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.popup-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.popup-actions .btn {
    min-width: 150px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Screen Styles */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('Assets/BACKGROUND.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.login-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.login-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.5s ease;
}

.login-title {
    text-align: center;
    font-size: 2em;
    margin-bottom: 30px;
    color: #333;
    font-weight: 700;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-input-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: inherit;
    background: white;
}

.login-input:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.btn-login {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(34, 197, 94, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.login-error {
    color: #dc3545;
    text-align: center;
    font-size: 14px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(220, 53, 69, 0.1);
    border-radius: 8px;
    animation: shake 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modern-spinner {
    position: relative;
    width: 100px;
    height: 100px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
    animation-delay: -0.45s;
    border-top-color: #22c55e;
    border-width: 4px;
}

.spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
    border-top-color: #16a34a;
    border-width: 4px;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
}

.spinner-ring:nth-child(3) {
    animation-delay: -0.15s;
    border-top-color: #15803d;
    border-width: 4px;
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive Login */
@media (max-width: 768px) {
    .login-content {
        padding: 30px 20px;
    }

    .login-title {
        font-size: 1.5em;
    }

    .modern-spinner {
        width: 80px;
        height: 80px;
    }
    
    .spinner-ring {
        border-width: 3px;
    }
}

