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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
}

.email-generator {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

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

.email-display {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#currentEmail {
    flex: 1;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f5f5f5;
}

.btn-copy {
    padding: 15px 25px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-copy:hover:not(:disabled) {
    background: #45a049;
}

.btn-copy:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.btn-generate {
    width: 100%;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-generate:hover:not(:disabled) {
    background: #5568d3;
}

.btn-generate:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.info {
    margin-top: 15px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.custom-email-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.custom-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-custom {
    padding: 15px;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}

#createBtn {
    background: #667eea;
}

#createBtn:hover:not(:disabled) {
    background: #5568d3;
}

#accessBtn {
    background: #4CAF50;
}

#accessBtn:hover:not(:disabled) {
    background: #45a049;
}

.btn-custom:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Custom email input: match style of #currentEmail */
#customEmail {
    flex: 1;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f5f5f5;
    outline: none;
}

#customEmail:focus {
    border-color: #667eea;
}

.domain-suffix {
    font-size: 1.1rem;
    color: #667eea;
    font-weight: bold;
}

.availability-message {
    min-height: 24px;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}

.availability-message.available {
    background: #e8f5e9;
    color: #2e7d32;
}

.availability-message.unavailable {
    background: #ffebee;
    color: #c62828;
}

.availability-message.checking {
    background: #fff3e0;
    color: #e65100;
}

.availability-message.error {
    background: #ffebee;
    color: #c62828;
}

/* Compose Modal */
#composeModal .modal-content {
    max-width: 600px;
}

#composeModal h2 {
    margin-bottom: 20px;
    color: #333;
}

.compose-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: bold;
    color: #555;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input[readonly] {
    background: #f5f5f5;
    color: #666;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-send {
    flex: 1;
    padding: 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-send:hover:not(:disabled) {
    background: #45a049;
}

.btn-send:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.btn-cancel {
    padding: 12px 30px;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-cancel:hover {
    background: #d0d0d0;
}

.close-compose {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
}

.close-compose:hover {
    color: #333;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 15px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-indicator p {
    color: #667eea;
    font-size: 1rem;
    font-weight: bold;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Refresh button loading state */
.btn-refresh.loading {
    position: relative;
    color: transparent;
}

.btn-refresh.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.inbox {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    min-height: 400px;
}

.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.inbox-header h2 {
    color: #333;
}

#emailCount {
    color: #667eea;
    font-size: 0.9rem;
}

.inbox-actions {
    display: flex;
    gap: 10px;
}

.btn-compose {
    padding: 10px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-compose:hover:not(:disabled) {
    background: #45a049;
}

.btn-compose:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.btn-refresh {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-refresh:hover {
    background: #5568d3;
}

.email-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p:first-child {
    font-size: 3rem;
    margin-bottom: 10px;
}

.empty-state .small {
    font-size: 0.9rem;
}

.email-item {
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.email-item:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateX(5px);
}

.email-item .email-from {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.email-item .email-subject {
    color: #667eea;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.email-item .email-preview {
    color: #4a5568;
    font-size: 0.95rem;
    margin-bottom: 8px;
    line-height: 1.5;
}

.email-item .email-date {
    color: #718096;
    font-size: 0.85rem;
    font-weight: 500;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

#emailDetail .detail-from,
#emailDetail .detail-subject,
#emailDetail .detail-date {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

#emailDetail .detail-label {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

#emailDetail .detail-body {
    margin-top: 20px;
    line-height: 1.8;
    color: #2d3748;
    font-size: 1rem;
}

#emailDetail .detail-body a {
    color: #667eea;
    text-decoration: underline;
}

footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    padding: 20px;
}

footer p {
    margin: 5px 0;
}

footer .small {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .email-display {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}
