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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
    background: #f2f2f7;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-size: 17px;
    line-height: 1.4;
}

.container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 0.5px solid rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 100%;
    text-align: center;
    animation: slideIn 0.6s ease-out;
}

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

.header {
    margin: -24px -24px 32px -24px;
    padding: 32px 24px 24px 24px;
    background: linear-gradient(135deg, #007aff 0%, #5856d6 50%, #af52de 100%);
    border-radius: 16px 16px 0 0;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" fill="rgba(255,255,255,0.1)"><polygon points="0,0 1000,0 1000,80 0,100"/></svg>') no-repeat bottom;
    background-size: 100% 20px;
    pointer-events: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.title-section {
    flex: 1;
    text-align: left;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.header h1 {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #ffffff;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background: linear-gradient(45deg, #ffffff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 17px;
    font-weight: 500;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.header-decoration {
    display: flex;
    align-items: center;
    justify-content: center;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.security-badge i {
    font-size: 16px;
}

/* Icon Button Styles */
.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: relative;
    background: #f2f2f7;
    padding: 0;
}

.icon-btn:hover {
    transform: scale(0.95);
    background: #e5e5ea;
}

.icon-btn:active {
    transform: scale(0.9);
}

.icon-btn.add-account-btn {
    color: #007aff;
    background: #f2f2f7;
}

.icon-btn.add-account-btn:hover {
    background: #e5e5ea;
}

.icon-btn.btn-export {
    color: #34c759;
    background: #f2f2f7;
}

.icon-btn.btn-export:hover {
    background: #e5e5ea;
}

.icon-btn.btn-import {
    color: #af52de;
    background: #f2f2f7;
}

.icon-btn.btn-import:hover {
    background: #e5e5ea;
}

.icon-btn.btn-encrypt {
    color: #6c757d;
    background: #f2f2f7;
    transition: all 0.2s ease;
}

.icon-btn.btn-encrypt:hover {
    background: #e5e5ea;
}

.accounts-counter {
    display: inline-block;
    background: #ff3b30;
    color: white;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    margin-left: 8px;
    min-width: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 24px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1c1c1e;
    font-size: 17px;
}

.input-container {
    position: relative;
}

.form-group input {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid #d1d1d6;
    border-radius: 12px;
    font-size: 17px;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    background: #ffffff;
    color: #1c1c1e;
}

.form-group input:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.input-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: #999;
    pointer-events: none;
}

.accounts-list {
    margin: 20px 0;
}

.account-card {
    margin-bottom: 12px;
    padding: 16px;
    background: #ffffff;
    border-radius: 12px;
    border: 0.5px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    animation: slideInUp 0.4s ease-out;
    position: relative;
}

.account-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Allow text to truncate */
}

.account-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1c1c1e;
    margin: 0;
    letter-spacing: -0.2px;
    text-align: left;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Circular Timer */
.circular-timer {
    width: 24px;
    height: 24px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
}

.circular-timer svg {
    width: 24px;
    height: 24px;
    transform: rotate(-90deg);
}

.circular-timer .circle-bg {
    fill: none;
    stroke: #e5e5ea;
    stroke-width: 2;
}

.circular-timer .circle-progress {
    fill: none;
    stroke: #007aff;
    stroke-width: 2;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}

.circular-timer .timer-number {
    position: absolute;
    font-size: 8px;
    font-weight: 600;
    color: #007aff;
    line-height: 1;
}

.account-info .issuer {
    color: #8e8e93;
    font-size: 15px;
    font-weight: 400;
    margin-top: 4px;
}

.delete-btn {
    background: transparent;
    color: #ff3b30;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    position: relative;
    padding: 0;
}

.delete-btn:hover {
    background: rgba(255, 59, 48, 0.08);
    transform: scale(0.95);
}

.delete-btn:active {
    transform: scale(0.9);
}

.totp-display {
    margin: 16px 0;
    padding: 16px;
    background: #f2f2f7;
    border-radius: 12px;
    transition: all 0.2s ease;
    opacity: 1;
    transform: scale(1);
}

.totp-code-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.totp-code {
    font-size: 36px;
    font-weight: 700;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    color: #1c1c1e;
    letter-spacing: 3px;
    animation: pulse 2s infinite;
    flex: 1;
}

.copy-icon-btn {
    background: #007aff;
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
}

.copy-icon-btn:hover {
    background: #0051d0;
    transform: scale(0.95);
}

.copy-icon-btn:active {
    transform: scale(0.9);
}

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

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-state h3 {
    margin-bottom: 12px;
    color: #333;
    font-weight: 600;
}

.empty-state p {
    color: #8e8e93;
    line-height: 1.5;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.timer-container {
    display: none;
}

.timer-text {
    display: none;
}

.timer-progress {
    display: none;
}

.timer-bar {
    display: none;
}

.btn {
    width: 100%;
    padding: 16px;
    background: #007aff;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 16px;
    min-height: 50px; /* Better touch target */
    touch-action: manipulation; /* Prevent zoom on double-tap */
}

.btn:hover {
    background: #0051d0;
    transform: scale(0.98);
}

.btn:active {
    transform: scale(0.95);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.backup-controls {
    margin: 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.primary-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.backup-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-secondary {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
    padding: 8px 12px;
    background: transparent;
    color: #95a5a6;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation; /* Prevent zoom on double-tap */
}

.btn-secondary:hover {
    background: rgba(149, 165, 166, 0.1);
    color: #7f8c8d;
}

.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-export {
    color: #27ae60;
}

.btn-export:hover {
    background: rgba(39, 174, 96, 0.1);
    color: #229954;
}

.btn-import {
    color: #f39c12;
}

.btn-import:hover {
    background: rgba(243, 156, 18, 0.1);
    color: #e67e22;
}

#importFile {
    display: none;
}

.help-text {
    margin-top: 20px;
    padding: 15px;
    background: #ecf0f1;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    text-align: left;
}

.help-text h4 {
    margin-bottom: 10px;
    color: #333;
}

.help-text ul {
    margin-left: 20px;
    color: #666;
}

.help-text li {
    margin-bottom: 5px;
}

.account-name {
    margin-bottom: 10px;
}

.error-message {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 5px;
    font-weight: 500;
}

.success-message {
    color: #28a745;
    font-size: 0.9rem;
    margin-top: 5px;
    font-weight: 500;
}

.app-footer {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
}

.app-footer p {
    font-size: 13px;
    color: #8e8e93;
    margin: 4px 0;
    line-height: 1.4;
}

.app-footer a {
    color: #007aff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.app-footer a:hover {
    color: #0051d0;
    text-decoration: underline;
}

@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: flex-start;
    }

    .container {
        padding: 16px;
        margin: 0;
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .accounts-list {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .empty-state {
        padding: 40px 20px 20px 20px;
        margin-top: 0;
        text-align: center;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .header {
        margin: -16px -16px 24px -16px;
        padding: 24px 16px 20px 16px;
    }

    .header h1 {
        font-size: 32px;
        font-weight: 800;
    }

    .header p {
        font-size: 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 16px;
        text-align: center;
    }

    .title-section {
        text-align: center;
    }

    .security-badge {
        font-size: 13px;
        padding: 10px 14px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .backup-controls {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 15px;
    }

    .primary-actions,
    .backup-actions {
        gap: 8px;
    }

    .accounts-counter {
        font-size: 0.7rem;
        padding: 3px 8px;
        margin-left: 8px;
    }

    .form-group input {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .input-icon {
        right: 12px;
        font-size: 1rem;
    }

    .btn {
        padding: 12px;
        font-size: 1rem;
    }

    .account-card {
        padding: 12px;
        margin-bottom: 8px;
    }

    .account-header {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .account-info {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .account-info h3 {
        font-size: 1.1rem;
        text-align: left;
    }

    .circular-timer {
        width: 20px;
        height: 20px;
        margin-left: 6px;
    }

    .circular-timer svg {
        width: 20px;
        height: 20px;
    }

    .circular-timer .timer-number {
        font-size: 7px;
    }

    .account-info .issuer {
        font-size: 0.8rem;
    }

    .delete-btn {
        align-self: flex-end;
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .totp-display {
        padding: 12px;
        margin: 12px 0;
    }

    .totp-code-container {
        gap: 8px;
    }

    .totp-code {
        font-size: 1.8rem;
        letter-spacing: 2px;
    }

    .copy-icon-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .empty-state {
        padding: 40px 20px 20px 20px;
        margin-top: 0;
        text-align: center;
    }

    .empty-state .empty-icon {
        font-size: 2.5rem;
        margin-bottom: 16px;
    }

    .empty-state h3 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .empty-state p {
        font-size: 1rem;
        color: #8e8e93;
        margin: 0;
    }

    .app-footer {
        margin-top: 30px;
        padding: 16px 0;
    }

    .app-footer p {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .container {
        padding: 12px;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .header {
        margin: -12px -12px 20px -12px;
        padding: 20px 12px 16px 12px;
    }

    .header h1 {
        font-size: 28px;
    }

    .header p {
        font-size: 15px;
    }

    .header-content {
        gap: 12px;
    }

    .security-badge {
        font-size: 12px;
        padding: 8px 12px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .form-group input {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .account-card {
        padding: 15px;
    }

    .totp-code {
        font-size: 2rem;
        letter-spacing: 3px;
    }

    .copy-icon-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .backup-controls {
        margin: 15px 0;
    }

    .app-footer {
        margin-top: 25px;
        padding: 12px 0;
    }

    .app-footer p {
        font-size: 11px;
    }
}

@media (min-width: 601px) and (max-width: 768px) {
    body {
        padding: 0;
        align-items: flex-start;
    }

    .container {
        max-width: 100%;
        width: 100%;
        padding: 35px;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .accounts-list {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .empty-state {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

@media (min-width: 769px) {
    .container {
        max-width: 500px;
    }

    .backup-controls {
        flex-direction: row;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Drawer Styles */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: #ffffff;
    border-left: 0.5px solid rgba(0, 0, 0, 0.04);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 999;
    transition: right 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    padding: 0;
    transform: translateX(100%);
    visibility: hidden;
}

.drawer.active {
    right: 0;
    transform: translateX(0);
    visibility: visible;
}

.drawer-header {
    background: #f2f2f7;
    color: #1c1c1e;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.04);
}

.drawer-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.24px;
}

.drawer-close {
    background: #e5e5ea;
    color: #8e8e93;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.drawer-close:hover {
    background: #d1d1d6;
    transform: scale(0.95);
}

.drawer-close:active {
    transform: scale(0.9);
}

.drawer #totpForm {
    padding: 24px;
    background: transparent;
}

.drawer .form-group {
    margin-bottom: 25px;
}

.drawer .btn {
    margin-top: 20px;
}

/* Mobile drawer adjustments */
@media (max-width: 768px) {
    .drawer {
        width: 100%;
        max-width: none;
        right: -100%;
        transform: translateX(100%);
    }
    
    .drawer.active {
        right: 0;
        transform: translateX(0);
    }
    
    .drawer-header {
        padding: 20px;
    }
    
    .drawer-header h3 {
        font-size: 1.3rem;
    }
    
    .drawer #totpForm {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .drawer-header {
        padding: 15px;
    }
    
    .drawer-header h3 {
        font-size: 1.2rem;
    }
    
    .drawer #totpForm {
        padding: 15px;
    }
    
    .drawer-close {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

/* Form Label with Action Button */
.label-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.label-with-action label[for] {
    margin: 0;
    font-weight: 600;
    color: #1d1d1f;
    font-size: 15px;
}

.qr-scan-btn {
    padding: 6px 8px !important;
    font-size: 14px !important;
    min-width: auto !important;
    width: auto !important;
    height: auto !important;
}

.qr-scan-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.qr-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 122, 255, 0.1);
    border-radius: 8px;
    color: #007aff;
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
}

.qr-progress .fa-spinner {
    animation: spin 1s linear infinite;
}

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