/**
 * TTLock Frontend Styles
 */

/* General TTLock Styles */
.ttlock-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
}

/* MotoPress Account Integration Styles */
.mphb-ttlock-dashboard-section,
.mphb-ttlock-bookings-section,
.mphb-ttlock-content {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.mphb-ttlock-dashboard-section h3,
.mphb-ttlock-bookings-section h3,
.mphb-ttlock-content h2 {
    margin-top: 0;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.mphb-ttlock-dashboard-section h3:before {
    content: "🔑";
    font-size: 20px;
}

.mphb-ttlock-bookings-section h3:before {
    content: "🏠";
    font-size: 20px;
}

.mphb-ttlock-content h2:before {
    content: "🔐";
    font-size: 24px;
}

/* TTLock Tabs Interface */
.ttlock-user-interface {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ttlock-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.ttlock-tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.ttlock-tab-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.ttlock-tab-btn.active {
    background: #fff;
    color: #007cba;
    border-bottom-color: #007cba;
}

.ttlock-tab-content {
    display: none;
    padding: 20px;
}

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

/* Keys Grid for Account Integration */
.ttlock-keys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.ttlock-key-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    transition: all 0.2s ease;
}

.ttlock-key-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.key-info {
    margin-bottom: 12px;
}

.key-room {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
    display: block;
}

.key-dates {
    color: #6c757d;
    font-size: 14px;
    display: block;
    margin-top: 4px;
}

.key-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.key-pin {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-size: 14px;
    letter-spacing: 1px;
}

.ttlock-btn-copy {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.ttlock-btn-copy:hover {
    background: #005a87;
}

/* Upcoming Access Section */
.ttlock-upcoming-list {
    margin-top: 15px;
}

.ttlock-upcoming-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 10px;
}

.booking-info {
    flex: 1;
}

.booking-id {
    font-weight: 600;
    color: #2c3e50;
    display: block;
}

.booking-room,
.booking-dates {
    display: block;
    color: #6c757d;
    font-size: 14px;
    margin-top: 2px;
}

.status-ready {
    background: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Booking Keys Section */
.ttlock-booking-keys {
    margin-top: 15px;
}

.booking-keys-group {
    margin-bottom: 20px;
}

.booking-keys-group h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 16px;
    padding-bottom: 5px;
    border-bottom: 1px solid #dee2e6;
}

.keys-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.key-item {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.key-item .key-room {
    font-weight: 600;
    min-width: 80px;
    color: #2c3e50;
}

.key-item .key-pin {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px solid #dee2e6;
    font-size: 13px;
    letter-spacing: 1px;
}

.key-item .key-validity {
    color: #6c757d;
    font-size: 12px;
    flex: 1;
}

.key-item .btn-copy-pin {
    background: #28a745;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s ease;
}

.key-item .btn-copy-pin:hover {
    background: #218838;
}

/* Active Keys List */
.ttlock-active-keys-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.ttlock-key-item {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.ttlock-key-item .key-details h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 18px;
}

.ttlock-key-item .key-meta {
    margin-bottom: 15px;
}

.ttlock-key-item .key-booking,
.ttlock-key-item .key-validity {
    display: block;
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 5px;
}

.ttlock-key-item .key-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.ttlock-key-item .pin-display {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.ttlock-key-item .pin-label {
    font-weight: 500;
    color: #495057;
}

.ttlock-key-item .pin-code {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-size: 16px;
    letter-spacing: 2px;
}

.ttlock-key-item .btn-copy-pin {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.ttlock-key-item .btn-copy-pin:hover {
    background: #005a87;
}

.ttlock-key-item .status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.status-active {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-expired {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.status-pending {
    background: #fff3cd;
    color: #856404;
}

/* Tables */
.ttlock-history-table,
.ttlock-requests-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.ttlock-history-table th,
.ttlock-history-table td,
.ttlock-requests-table th,
.ttlock-requests-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.ttlock-history-table th,
.ttlock-requests-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

/* Access Requests Form */
.request-form {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.request-form h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

.ttlock-btn-primary {
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.ttlock-btn-primary:hover {
    background: #005a87;
}

/* My Keys Component */
.ttlock-my-keys-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.ttlock-section-title {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

.ttlock-icon {
    margin-right: 12px;
    font-size: 32px;
}

/* PIN Cards Grid */
.ttlock-pins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.ttlock-pin-card {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border: 2px solid #e9ecef;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ttlock-pin-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ttlock-pin-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.ttlock-pin-card:hover::before {
    opacity: 1;
}

.ttlock-pin-card.active {
    border-color: #27ae60;
}

.ttlock-pin-card.active::before {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    opacity: 1;
}

.ttlock-pin-card.expired {
    border-color: #e74c3c;
    opacity: 0.8;
    background: linear-gradient(135deg, #fff 0%, #fdf2f2 100%);
}

.ttlock-pin-card.expired::before {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
    opacity: 1;
}

/* PIN Card Header */
.pin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.room-name {
    margin: 0;
    display: flex;
    align-items: center;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.room-icon {
    margin-right: 10px;
    font-size: 24px;
}

.pin-status {
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-expired {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-cancelled {
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    color: #856404;
    border: 1px solid #fdcb6e;
}

/* PIN Code Section */
.pin-code-section {
    margin-bottom: 25px;
}

.pin-code-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #5a6c7d;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pin-code-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pin-code {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 18px 24px;
    font-size: 28px;
    font-weight: 700;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    letter-spacing: 3px;
    color: #2c3e50;
    flex: 1;
    text-align: center;
    transition: all 0.3s ease;
    cursor: text;
    user-select: all;
}

.pin-code:hover {
    border-color: #3498db;
    background: linear-gradient(135deg, #fff, #f8f9fa);
}

.copy-pin-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: none;
    border-radius: 12px;
    padding: 18px;
    color: white;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.copy-pin-btn:hover {
    background: linear-gradient(135deg, #2980b9, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.copy-pin-btn:active {
    transform: translateY(0);
}

/* PIN Validity */
.pin-validity {
    margin-bottom: 25px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
}

.validity-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.validity-item:last-child {
    margin-bottom: 0;
}

.validity-label {
    color: #6c757d;
    font-weight: 500;
    font-size: 14px;
}

.validity-date {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

/* PIN Actions */
.pin-actions {
    margin-bottom: 20px;
}

.open-door-btn {
    width: 100%;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.open-door-btn:hover {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.open-door-btn:active {
    transform: translateY(0);
}

.open-door-btn:disabled {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    font-size: 18px;
}

/* Booking Reference */
.booking-reference {
    text-align: center;
    color: #7f8c8d;
    font-size: 13px;
    font-style: italic;
}

/* Instructions Section */
.ttlock-instructions {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 16px;
    padding: 30px;
    margin-top: 40px;
    border: 1px solid #dee2e6;
}

.ttlock-instructions h4 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.ttlock-instructions h4::before {
    content: '📋';
    margin-right: 10px;
    font-size: 24px;
}

.ttlock-instructions ol {
    margin-bottom: 25px;
    padding-left: 20px;
}

.ttlock-instructions li {
    margin-bottom: 10px;
    color: #5a6c7d;
    font-size: 15px;
    line-height: 1.6;
}

.help-text {
    background: linear-gradient(135deg, #e8f4fd, #d1ecf1);
    border-left: 4px solid #3498db;
    padding: 16px 20px;
    margin: 0;
    border-radius: 0 12px 12px 0;
    font-size: 15px;
    line-height: 1.6;
}

.help-text strong {
    color: #2c3e50;
}

/* No PINs State */
.ttlock-no-pins {
    text-align: center;
    padding: 60px 30px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 16px;
    border: 2px dashed #dee2e6;
}

.no-pins-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.7;
}

.ttlock-no-pins h4 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 22px;
    font-weight: 600;
}

.ttlock-no-pins p {
    color: #6c757d;
    margin: 0;
    font-size: 16px;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Door Control Standalone */
.ttlock-door-control {
    text-align: center;
    margin: 20px 0;
}

.ttlock-open-door-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: none;
    border-radius: 12px;
    padding: 16px 32px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ttlock-open-door-btn:hover {
    background: linear-gradient(135deg, #2980b9, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Success/Error Animations */
.success-animation {
    animation: successPulse 0.6s ease;
}

.error-animation {
    animation: errorShake 0.6s ease;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .ttlock-my-keys-container {
        padding: 15px;
    }
    
    .ttlock-pins-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .ttlock-section-title {
        font-size: 24px;
    }
    
    .pin-code {
        font-size: 24px;
        padding: 16px 20px;
        letter-spacing: 2px;
    }
    
    .pin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .pin-status {
        align-self: flex-end;
    }
    
    .ttlock-instructions {
        padding: 20px;
    }
    
    .ttlock-no-pins {
        padding: 40px 20px;
    }
    
    .no-pins-icon {
        font-size: 48px;
    }
}

/* Mobile responsiveness for modal */
@media (max-width: 768px) {
    .ttlock-help-content {
        width: 95%;
        margin: 1em;
    }
    
    .ttlock-help-header,
    .ttlock-help-body {
        padding: 1.5em;
    }
    
    .ttlock-help-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .pin-code-display {
        flex-direction: column;
        gap: 15px;
    }
    
    .copy-pin-btn {
        width: 100%;
        padding: 16px;
    }
    
    .validity-item {
        flex-direction: column;
        gap: 4px;
    }
    
    .validity-label {
        font-weight: 600;
    }
}

/* Print Styles */
@media print {
    .open-door-btn,
    .copy-pin-btn,
    .ttlock-instructions {
        display: none;
    }
    
    .ttlock-pin-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .pin-code {
        border: 1px solid #000;
        background: white;
    }
}

/* Help Modal Styles */
.ttlock-help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.ttlock-help-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.ttlock-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5em 2em;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.ttlock-help-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.4em;
}

.ttlock-help-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ttlock-help-close:hover {
    background: #e0e0e0;
    color: #333;
}

.ttlock-help-body {
    padding: 2em;
}

.ttlock-help-body h4 {
    color: #333;
    margin: 1.5em 0 1em 0;
    font-size: 1.1em;
}

.ttlock-help-body ol,
.ttlock-help-body ul {
    padding-left: 1.5em;
    margin-bottom: 1.5em;
}

.ttlock-help-body li {
    margin-bottom: 0.5em;
    line-height: 1.6;
}

.ttlock-help-actions {
    display: flex;
    gap: 1em;
    margin-top: 2em;
    padding-top: 1.5em;
    border-top: 1px solid #e0e0e0;
}

.ttlock-help-actions .ttlock-btn {
    flex: 1;
    padding: 0.8em 1.2em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    transition: all 0.3s ease;
}

.ttlock-btn-primary {
    background: #007cba;
    color: white;
}

.ttlock-btn-primary:hover {
    background: #005a87;
    color: white;
}

.ttlock-btn-secondary {
    background: #6c757d;
    color: white;
}

.ttlock-btn-secondary:hover {
    background: #545b62;
    color: white;
}

/* Modal Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
